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 | 4a79ba34 | 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 | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 131 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 132 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 134 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 135 | const struct hda_pcm_stream *stream_analog_playback; |
| 136 | const struct hda_pcm_stream *stream_analog_capture; |
| 137 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 138 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 140 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 141 | const struct hda_pcm_stream *stream_digital_playback; |
| 142 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
| 144 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 145 | struct hda_multi_out multiout; /* playback set-up |
| 146 | * max_channels, dacs must be set |
| 147 | * dig_out_nid and hp_nid are optional |
| 148 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 149 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 150 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 151 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | /* capture */ |
| 154 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 155 | const hda_nid_t *adc_nids; |
| 156 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 157 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 158 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 160 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 161 | hda_nid_t cur_adc; |
| 162 | unsigned int cur_adc_stream_tag; |
| 163 | unsigned int cur_adc_format; |
| 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 166 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | const struct hda_input_mux *input_mux; |
| 168 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 169 | hda_nid_t ext_mic_pin; |
| 170 | hda_nid_t dock_mic_pin; |
| 171 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
| 173 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 174 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 176 | int need_dac_fix; |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 177 | int const_channel_count; /* min. channel count (for speakers) */ |
| 178 | int ext_channel_count; /* current channel count for multi-io */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
| 180 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 181 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 182 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 183 | /* dynamic controls, init_verbs and input_mux */ |
| 184 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 185 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 186 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 187 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 188 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 189 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 190 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 191 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 192 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 193 | 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] | 194 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 195 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 196 | /* DAC list */ |
| 197 | int num_all_dacs; |
| 198 | hda_nid_t all_dacs[16]; |
| 199 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 200 | /* path list */ |
| 201 | struct snd_array paths; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 202 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 203 | /* hooks */ |
| 204 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 205 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 206 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 207 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 208 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 209 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 210 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 211 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 212 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 213 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 214 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 215 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 216 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 217 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 218 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 219 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 220 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 221 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 222 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 223 | 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] | 224 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 225 | /* other flags */ |
| 226 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 227 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 228 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 229 | 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] | 230 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 231 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 232 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 233 | 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] | 234 | 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] | 235 | |
| 236 | /* auto-mute control */ |
| 237 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 238 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 239 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 240 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 241 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 242 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 243 | /* for virtual master */ |
| 244 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 245 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 246 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 247 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 248 | int num_loopbacks; |
| 249 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 250 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 251 | |
| 252 | /* for PLL fix */ |
| 253 | hda_nid_t pll_nid; |
| 254 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 255 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 256 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 257 | /* multi-io */ |
| 258 | int multi_ios; |
| 259 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 260 | |
| 261 | /* bind volumes */ |
| 262 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 265 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 266 | int dir, unsigned int bits) |
| 267 | { |
| 268 | if (!nid) |
| 269 | return false; |
| 270 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 271 | if (query_amp_caps(codec, nid, dir) & bits) |
| 272 | return true; |
| 273 | return false; |
| 274 | } |
| 275 | |
| 276 | #define nid_has_mute(codec, nid, dir) \ |
| 277 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 278 | #define nid_has_volume(codec, nid, dir) \ |
| 279 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | /* |
| 282 | * input MUX handling |
| 283 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 284 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 285 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | { |
| 287 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 288 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 289 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 290 | if (mux_idx >= spec->num_mux_defs) |
| 291 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 292 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 293 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 294 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 297 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 298 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { |
| 300 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 301 | struct alc_spec *spec = codec->spec; |
| 302 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 303 | |
| 304 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 305 | return 0; |
| 306 | } |
| 307 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 308 | 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] | 309 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 310 | struct alc_spec *spec = codec->spec; |
| 311 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 312 | |
| 313 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 314 | /* stream is running, let's swap the current ADC */ |
| 315 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 316 | spec->cur_adc = new_adc; |
| 317 | snd_hda_codec_setup_stream(codec, new_adc, |
| 318 | spec->cur_adc_stream_tag, 0, |
| 319 | spec->cur_adc_format); |
| 320 | return true; |
| 321 | } |
| 322 | return false; |
| 323 | } |
| 324 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 325 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 326 | { |
| 327 | return spec->capsrc_nids ? |
| 328 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 329 | } |
| 330 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 331 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 332 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 333 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 334 | /* for shared I/O, change the pin-control accordingly */ |
| 335 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 336 | { |
| 337 | struct alc_spec *spec = codec->spec; |
| 338 | unsigned int val; |
| 339 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 340 | /* NOTE: this assumes that there are only two inputs, the |
| 341 | * first is the real internal mic and the second is HP/mic jack. |
| 342 | */ |
| 343 | |
| 344 | val = snd_hda_get_default_vref(codec, pin); |
| 345 | |
| 346 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 347 | instead, as suggested by Realtek */ |
| 348 | if (val == AC_PINCTL_VREF_HIZ) { |
| 349 | const hda_nid_t vref_pin = 0x18; |
| 350 | /* Sanity check pin 0x18 */ |
| 351 | if (get_wcaps_type(get_wcaps(codec, vref_pin)) == AC_WID_PIN && |
| 352 | get_defcfg_connect(snd_hda_codec_get_pincfg(codec, vref_pin)) == AC_JACK_PORT_NONE) { |
| 353 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 354 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 355 | snd_hda_set_pin_ctl(codec, vref_pin, PIN_IN | (set_as_mic ? vref_val : 0)); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 360 | snd_hda_set_pin_ctl(codec, pin, val); |
| 361 | |
| 362 | spec->automute_speaker = !set_as_mic; |
| 363 | call_update_outputs(codec); |
| 364 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 365 | |
| 366 | /* select the given imux item; either unmute exclusively or select the route */ |
| 367 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 368 | unsigned int idx, bool force) |
| 369 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 371 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 372 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 373 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 374 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
Takashi Iwai | 5803a32 | 2012-02-21 11:59:45 +0100 | [diff] [blame] | 376 | if (!spec->input_mux) |
| 377 | return 0; |
| 378 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 379 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 380 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 381 | if (!imux->num_items && mux_idx > 0) |
| 382 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 383 | if (!imux->num_items) |
| 384 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 385 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 386 | if (idx >= imux->num_items) |
| 387 | idx = imux->num_items - 1; |
| 388 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 389 | return 0; |
| 390 | spec->cur_mux[adc_idx] = idx; |
| 391 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 392 | if (spec->shared_mic_hp) |
| 393 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 394 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 395 | if (spec->dyn_adc_switch) { |
| 396 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 397 | adc_idx = spec->dyn_adc_idx[idx]; |
| 398 | } |
| 399 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 400 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 401 | |
| 402 | /* no selection? */ |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 403 | num_conns = snd_hda_get_num_conns(codec, nid); |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 404 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 405 | return 1; |
| 406 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 407 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 408 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 409 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 410 | int active = imux->items[idx].index; |
| 411 | for (i = 0; i < num_conns; i++) { |
| 412 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 413 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 414 | HDA_AMP_MUTE, v); |
| 415 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 416 | } else { |
| 417 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 418 | snd_hda_codec_write_cache(codec, nid, 0, |
| 419 | AC_VERB_SET_CONNECT_SEL, |
| 420 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 421 | } |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 422 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 423 | return 1; |
| 424 | } |
| 425 | |
| 426 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 427 | struct snd_ctl_elem_value *ucontrol) |
| 428 | { |
| 429 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 430 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 431 | return alc_mux_select(codec, adc_idx, |
| 432 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 433 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 436 | * set up the input pin config (depending on the given auto-pin type) |
| 437 | */ |
| 438 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 439 | int auto_pin_type) |
| 440 | { |
| 441 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 442 | if (auto_pin_type == AUTO_PIN_MIC) |
| 443 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 444 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 448 | * Append the given mixer and verb elements for the later use |
| 449 | * The mixer array is referred in build_controls(), and init_verbs are |
| 450 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 451 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 452 | 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] | 453 | { |
| 454 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 455 | return; |
| 456 | spec->mixers[spec->num_mixers++] = mix; |
| 457 | } |
| 458 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 459 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 460 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 461 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 462 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 463 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 464 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 465 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 466 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 467 | { } |
| 468 | }; |
| 469 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 470 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 471 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 472 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 473 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 474 | { } |
| 475 | }; |
| 476 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 477 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 478 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 479 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 480 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 481 | { } |
| 482 | }; |
| 483 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 484 | /* |
| 485 | * Fix hardware PLL issue |
| 486 | * On some codecs, the analog PLL gating control must be off while |
| 487 | * the default value is 1. |
| 488 | */ |
| 489 | static void alc_fix_pll(struct hda_codec *codec) |
| 490 | { |
| 491 | struct alc_spec *spec = codec->spec; |
| 492 | unsigned int val; |
| 493 | |
| 494 | if (!spec->pll_nid) |
| 495 | return; |
| 496 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 497 | spec->pll_coef_idx); |
| 498 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 499 | AC_VERB_GET_PROC_COEF, 0); |
| 500 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 501 | spec->pll_coef_idx); |
| 502 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 503 | val & ~(1 << spec->pll_coef_bit)); |
| 504 | } |
| 505 | |
| 506 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 507 | unsigned int coef_idx, unsigned int coef_bit) |
| 508 | { |
| 509 | struct alc_spec *spec = codec->spec; |
| 510 | spec->pll_nid = nid; |
| 511 | spec->pll_coef_idx = coef_idx; |
| 512 | spec->pll_coef_bit = coef_bit; |
| 513 | alc_fix_pll(codec); |
| 514 | } |
| 515 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 516 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 517 | * Jack detections for HP auto-mute and mic-switch |
| 518 | */ |
| 519 | |
| 520 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 521 | 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] | 522 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 523 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 524 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 525 | for (i = 0; i < num_pins; i++) { |
| 526 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 527 | if (!nid) |
| 528 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 529 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 530 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 531 | return present; |
| 532 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 533 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 534 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 535 | 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] | 536 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 537 | { |
| 538 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 539 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 540 | int i; |
| 541 | |
| 542 | for (i = 0; i < num_pins; i++) { |
| 543 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 544 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 545 | if (!nid) |
| 546 | break; |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 547 | /* don't reset VREF value in case it's controlling |
| 548 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 549 | */ |
| 550 | if (spec->keep_vref_in_automute) { |
| 551 | val = snd_hda_codec_read(codec, nid, 0, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 552 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 553 | val &= ~PIN_HP; |
| 554 | } else |
| 555 | val = 0; |
| 556 | val |= pin_bits; |
| 557 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 558 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 559 | } |
| 560 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 561 | /* Toggle outputs muting */ |
| 562 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 563 | { |
| 564 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 565 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 566 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 567 | /* Control HP pins/amps depending on master_mute state; |
| 568 | * in general, HP pins/amps control should be enabled in all cases, |
| 569 | * but currently set only for master_mute, just to be safe |
| 570 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 571 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 572 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 573 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 574 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 575 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 576 | on = 0; |
| 577 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 578 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 579 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 580 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 581 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 582 | |
| 583 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 584 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 585 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 586 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 587 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 588 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 589 | on = 0; |
| 590 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 591 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 592 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 593 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 594 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 595 | } |
| 596 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 597 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 598 | { |
| 599 | struct alc_spec *spec = codec->spec; |
| 600 | if (spec->automute_hook) |
| 601 | spec->automute_hook(codec); |
| 602 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 603 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 604 | } |
| 605 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 606 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 607 | 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] | 608 | { |
| 609 | struct alc_spec *spec = codec->spec; |
| 610 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 611 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 612 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 613 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 614 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 615 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 616 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 617 | } |
| 618 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 619 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 620 | 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] | 621 | { |
| 622 | struct alc_spec *spec = codec->spec; |
| 623 | |
David Henningsson | f7f4b232 | 2012-10-10 16:32:09 +0200 | [diff] [blame] | 624 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 625 | return; |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 626 | /* check LO jack only when it's different from HP */ |
| 627 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 628 | return; |
| 629 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 630 | spec->line_jack_present = |
| 631 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 632 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 633 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 634 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 635 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 636 | } |
| 637 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 638 | #define get_connection_index(codec, mux, nid) \ |
| 639 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 640 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 641 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 642 | 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] | 643 | { |
| 644 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 645 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 646 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 647 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 648 | return; |
| 649 | if (snd_BUG_ON(!spec->adc_nids)) |
| 650 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 651 | 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] | 652 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 653 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 654 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 655 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 656 | else if (spec->dock_mic_idx >= 0 && |
| 657 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 658 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 659 | else |
| 660 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 661 | } |
| 662 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 663 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 664 | 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] | 665 | { |
| 666 | unsigned int val; |
| 667 | struct snd_kcontrol *kctl; |
| 668 | struct snd_ctl_elem_value *uctl; |
| 669 | |
| 670 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 671 | if (!kctl) |
| 672 | return; |
| 673 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 674 | if (!uctl) |
| 675 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 676 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 677 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 678 | val &= HDA_AMP_VOLMASK; |
| 679 | uctl->value.integer.value[0] = val; |
| 680 | uctl->value.integer.value[1] = val; |
| 681 | kctl->put(kctl, uctl); |
| 682 | kfree(uctl); |
| 683 | } |
| 684 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 685 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 686 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 687 | /* For some reason, the res given from ALC880 is broken. |
| 688 | Here we adjust it properly. */ |
| 689 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 690 | } |
| 691 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 692 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 693 | static void alc_inithook(struct hda_codec *codec) |
| 694 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 695 | alc_hp_automute(codec, NULL); |
| 696 | alc_line_automute(codec, NULL); |
| 697 | alc_mic_automute(codec, NULL); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 698 | } |
| 699 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 700 | /* additional initialization for ALC888 variants */ |
| 701 | static void alc888_coef_init(struct hda_codec *codec) |
| 702 | { |
| 703 | unsigned int tmp; |
| 704 | |
| 705 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 706 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 707 | 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] | 708 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 709 | /* alc888S-VC */ |
| 710 | snd_hda_codec_read(codec, 0x20, 0, |
| 711 | AC_VERB_SET_PROC_COEF, 0x830); |
| 712 | else |
| 713 | /* alc888-VB */ |
| 714 | snd_hda_codec_read(codec, 0x20, 0, |
| 715 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 716 | } |
| 717 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 718 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 719 | static void alc889_coef_init(struct hda_codec *codec) |
| 720 | { |
| 721 | unsigned int tmp; |
| 722 | |
| 723 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 724 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 725 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 726 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 727 | } |
| 728 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 729 | /* turn on/off EAPD control (only if available) */ |
| 730 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 731 | { |
| 732 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 733 | return; |
| 734 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 735 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 736 | on ? 2 : 0); |
| 737 | } |
| 738 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 739 | /* turn on/off EAPD controls of the codec */ |
| 740 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 741 | { |
| 742 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 743 | static hda_nid_t pins[] = { |
| 744 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 745 | }; |
| 746 | hda_nid_t *p; |
| 747 | for (p = pins; *p; p++) |
| 748 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 749 | } |
| 750 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 751 | /* generic shutup callback; |
| 752 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 753 | */ |
| 754 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 755 | { |
| 756 | alc_auto_setup_eapd(codec, false); |
| 757 | msleep(200); |
| 758 | } |
| 759 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 760 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 761 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 762 | { |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 763 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 764 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 765 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 766 | switch (type) { |
| 767 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 768 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 769 | break; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 770 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 771 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 772 | break; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 773 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 774 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 775 | break; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 776 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 777 | switch (codec->vendor_id) { |
| 778 | case 0x10ec0260: |
| 779 | snd_hda_codec_write(codec, 0x1a, 0, |
| 780 | AC_VERB_SET_COEF_INDEX, 7); |
| 781 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 782 | AC_VERB_GET_PROC_COEF, 0); |
| 783 | snd_hda_codec_write(codec, 0x1a, 0, |
| 784 | AC_VERB_SET_COEF_INDEX, 7); |
| 785 | snd_hda_codec_write(codec, 0x1a, 0, |
| 786 | AC_VERB_SET_PROC_COEF, |
| 787 | tmp | 0x2010); |
| 788 | break; |
| 789 | case 0x10ec0262: |
| 790 | case 0x10ec0880: |
| 791 | case 0x10ec0882: |
| 792 | case 0x10ec0883: |
| 793 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 794 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 795 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 796 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 797 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 798 | case 0x10ec0888: |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 799 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 800 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 801 | #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] | 802 | case 0x10ec0267: |
| 803 | case 0x10ec0268: |
| 804 | snd_hda_codec_write(codec, 0x20, 0, |
| 805 | AC_VERB_SET_COEF_INDEX, 7); |
| 806 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 807 | AC_VERB_GET_PROC_COEF, 0); |
| 808 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 809 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 810 | snd_hda_codec_write(codec, 0x20, 0, |
| 811 | AC_VERB_SET_PROC_COEF, |
| 812 | tmp | 0x3000); |
| 813 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 814 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 815 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 816 | break; |
| 817 | } |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 818 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 819 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 820 | /* |
| 821 | * Auto-Mute mode mixer enum support |
| 822 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 823 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 824 | struct snd_ctl_elem_info *uinfo) |
| 825 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 826 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 827 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 828 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 829 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 830 | }; |
| 831 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 832 | if (spec->automute_speaker_possible && spec->automute_lo_possible) |
| 833 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 834 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 838 | struct snd_ctl_elem_value *ucontrol) |
| 839 | { |
| 840 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 841 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 842 | unsigned int val = 0; |
| 843 | if (spec->automute_speaker) |
| 844 | val++; |
| 845 | if (spec->automute_lo) |
| 846 | val++; |
| 847 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 848 | ucontrol->value.enumerated.item[0] = val; |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 853 | struct snd_ctl_elem_value *ucontrol) |
| 854 | { |
| 855 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 856 | struct alc_spec *spec = codec->spec; |
| 857 | |
| 858 | switch (ucontrol->value.enumerated.item[0]) { |
| 859 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 860 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 861 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 862 | spec->automute_speaker = 0; |
| 863 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 864 | break; |
| 865 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 866 | if (spec->automute_speaker_possible) { |
| 867 | if (!spec->automute_lo && spec->automute_speaker) |
| 868 | return 0; |
| 869 | spec->automute_speaker = 1; |
| 870 | spec->automute_lo = 0; |
| 871 | } else if (spec->automute_lo_possible) { |
| 872 | if (spec->automute_lo) |
| 873 | return 0; |
| 874 | spec->automute_lo = 1; |
| 875 | } else |
| 876 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 877 | break; |
| 878 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 879 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 880 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 881 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 882 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 883 | spec->automute_speaker = 1; |
| 884 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 885 | break; |
| 886 | default: |
| 887 | return -EINVAL; |
| 888 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 889 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 890 | return 1; |
| 891 | } |
| 892 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 893 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 894 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 895 | .name = "Auto-Mute Mode", |
| 896 | .info = alc_automute_mode_info, |
| 897 | .get = alc_automute_mode_get, |
| 898 | .put = alc_automute_mode_put, |
| 899 | }; |
| 900 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 901 | static struct snd_kcontrol_new * |
| 902 | alc_kcontrol_new(struct alc_spec *spec, const char *name, |
| 903 | const struct snd_kcontrol_new *temp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 904 | { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 905 | struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); |
| 906 | if (!knew) |
| 907 | return NULL; |
| 908 | *knew = *temp; |
| 909 | knew->name = kstrdup(name, GFP_KERNEL); |
| 910 | if (!knew->name) |
| 911 | return NULL; |
| 912 | return knew; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 913 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 914 | |
| 915 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 916 | { |
| 917 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 918 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 919 | if (!alc_kcontrol_new(spec, "Auto-Mute Mode", &alc_automute_mode_enum)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 920 | return -ENOMEM; |
| 921 | return 0; |
| 922 | } |
| 923 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 924 | /* |
| 925 | * Check the availability of HP/line-out auto-mute; |
| 926 | * Set up appropriately if really supported |
| 927 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 928 | static int alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 929 | { |
| 930 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 931 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 932 | int present = 0; |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 933 | int i, err; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 934 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 935 | if (cfg->hp_pins[0]) |
| 936 | present++; |
| 937 | if (cfg->line_out_pins[0]) |
| 938 | present++; |
| 939 | if (cfg->speaker_pins[0]) |
| 940 | present++; |
| 941 | if (present < 2) /* need two different output types */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 942 | return 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 943 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 944 | if (!cfg->speaker_pins[0] && |
| 945 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 946 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 947 | sizeof(cfg->speaker_pins)); |
| 948 | cfg->speaker_outs = cfg->line_outs; |
| 949 | } |
| 950 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 951 | if (!cfg->hp_pins[0] && |
| 952 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 953 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 954 | sizeof(cfg->hp_pins)); |
| 955 | cfg->hp_outs = cfg->line_outs; |
| 956 | } |
| 957 | |
| 958 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 959 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 960 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 961 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 962 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 963 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 964 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 965 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 966 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 967 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 968 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 969 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 970 | if (cfg->speaker_outs) |
| 971 | for (i = 0; i < cfg->line_outs; i++) { |
| 972 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 973 | if (!is_jack_detectable(codec, nid)) |
| 974 | continue; |
| 975 | snd_printdd("realtek: Enable Line-Out " |
| 976 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 977 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 978 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 979 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 980 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 981 | spec->automute_lo_possible = spec->detect_hp; |
| 982 | } |
| 983 | |
| 984 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 985 | (spec->detect_hp || spec->detect_lo); |
| 986 | |
| 987 | spec->automute_lo = spec->automute_lo_possible; |
| 988 | spec->automute_speaker = spec->automute_speaker_possible; |
| 989 | |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 990 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 991 | /* create a control for automute mode */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 992 | err = alc_add_automute_mode_enum(codec); |
| 993 | if (err < 0) |
| 994 | return err; |
| 995 | } |
| 996 | return 0; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 997 | } |
| 998 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 999 | /* 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] | 1000 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1001 | { |
| 1002 | int i; |
| 1003 | for (i = 0; i < nums; i++) |
| 1004 | if (list[i] == nid) |
| 1005 | return i; |
| 1006 | return -1; |
| 1007 | } |
| 1008 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1009 | /* check whether dynamic ADC-switching is available */ |
| 1010 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 1011 | { |
| 1012 | struct alc_spec *spec = codec->spec; |
| 1013 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 1014 | int i, n, idx; |
| 1015 | hda_nid_t cap, pin; |
| 1016 | |
| 1017 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1018 | return false; |
| 1019 | |
| 1020 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1021 | cap = spec->private_capsrc_nids[n]; |
| 1022 | for (i = 0; i < imux->num_items; i++) { |
| 1023 | pin = spec->imux_pins[i]; |
| 1024 | if (!pin) |
| 1025 | return false; |
| 1026 | if (get_connection_index(codec, cap, pin) < 0) |
| 1027 | break; |
| 1028 | } |
| 1029 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1030 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | for (i = 0; i < imux->num_items; i++) { |
| 1034 | pin = spec->imux_pins[i]; |
| 1035 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1036 | cap = spec->private_capsrc_nids[n]; |
| 1037 | idx = get_connection_index(codec, cap, pin); |
| 1038 | if (idx >= 0) { |
| 1039 | imux->items[i].index = idx; |
| 1040 | spec->dyn_adc_idx[i] = n; |
| 1041 | break; |
| 1042 | } |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1047 | spec->dyn_adc_switch = 1; |
| 1048 | return true; |
| 1049 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1050 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1051 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1052 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1053 | { |
| 1054 | struct alc_spec *spec = codec->spec; |
| 1055 | const struct hda_input_mux *imux; |
| 1056 | |
| 1057 | if (!spec->auto_mic) |
| 1058 | return false; |
| 1059 | if (spec->auto_mic_valid_imux) |
| 1060 | return true; /* already checked */ |
| 1061 | |
| 1062 | /* fill up imux indices */ |
| 1063 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1064 | spec->auto_mic = 0; |
| 1065 | return false; |
| 1066 | } |
| 1067 | |
| 1068 | imux = spec->input_mux; |
| 1069 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1070 | spec->imux_pins, imux->num_items); |
| 1071 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1072 | spec->imux_pins, imux->num_items); |
| 1073 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1074 | spec->imux_pins, imux->num_items); |
| 1075 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1076 | spec->auto_mic = 0; |
| 1077 | return false; /* no corresponding imux */ |
| 1078 | } |
| 1079 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1080 | snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, |
| 1081 | ALC_MIC_EVENT, alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1082 | if (spec->dock_mic_pin) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1083 | snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, |
| 1084 | ALC_MIC_EVENT, |
| 1085 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1086 | |
| 1087 | spec->auto_mic_valid_imux = 1; |
| 1088 | spec->auto_mic = 1; |
| 1089 | return true; |
| 1090 | } |
| 1091 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1092 | /* |
| 1093 | * Check the availability of auto-mic switch; |
| 1094 | * Set up if really supported |
| 1095 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1096 | static int alc_init_auto_mic(struct hda_codec *codec) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1097 | { |
| 1098 | struct alc_spec *spec = codec->spec; |
| 1099 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1100 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1101 | int i; |
| 1102 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1103 | if (spec->shared_mic_hp) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1104 | return 0; /* no auto-mic for the shared I/O */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1105 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1106 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1107 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1108 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1109 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1110 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1111 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1112 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1113 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1114 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1115 | if (fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1116 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1117 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1118 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1119 | fixed = nid; |
| 1120 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1121 | case INPUT_PIN_ATTR_UNUSED: |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1122 | return 0; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1123 | case INPUT_PIN_ATTR_DOCK: |
| 1124 | if (dock) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1125 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1126 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1127 | return 0; /* invalid type */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1128 | dock = nid; |
| 1129 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1130 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1131 | if (ext) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1132 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1133 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1134 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1135 | ext = nid; |
| 1136 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1137 | } |
| 1138 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1139 | if (!ext && dock) { |
| 1140 | ext = dock; |
| 1141 | dock = 0; |
| 1142 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1143 | if (!ext || !fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1144 | return 0; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1145 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1146 | return 0; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1147 | if (dock && !is_jack_detectable(codec, dock)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1148 | return 0; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1149 | |
| 1150 | /* check imux indices */ |
| 1151 | spec->ext_mic_pin = ext; |
| 1152 | spec->int_mic_pin = fixed; |
| 1153 | spec->dock_mic_pin = dock; |
| 1154 | |
| 1155 | spec->auto_mic = 1; |
| 1156 | if (!alc_auto_mic_check_imux(codec)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1157 | return 0; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1158 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1159 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1160 | ext, fixed, dock); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1161 | |
| 1162 | return 0; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1163 | } |
| 1164 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1165 | /* check the availabilities of auto-mute and auto-mic switches */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1166 | static int alc_auto_check_switches(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1167 | { |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1168 | int err; |
| 1169 | |
| 1170 | err = alc_init_automute(codec); |
| 1171 | if (err < 0) |
| 1172 | return err; |
| 1173 | err = alc_init_auto_mic(codec); |
| 1174 | if (err < 0) |
| 1175 | return err; |
| 1176 | return 0; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | /* |
| 1180 | * Realtek SSID verification |
| 1181 | */ |
| 1182 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1183 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1184 | * the driver to ignore any present sku defines. |
| 1185 | */ |
| 1186 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1187 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1188 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1189 | const struct hda_fixup *fix, int action) |
| 1190 | { |
| 1191 | struct alc_spec *spec = codec->spec; |
| 1192 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1193 | spec->cdefine.fixup = 1; |
| 1194 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1195 | } |
| 1196 | } |
| 1197 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1198 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1199 | { |
| 1200 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1201 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1202 | struct alc_spec *spec = codec->spec; |
| 1203 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1204 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1205 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1206 | if (spec->cdefine.fixup) { |
| 1207 | ass = spec->cdefine.sku_cfg; |
| 1208 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1209 | return -1; |
| 1210 | goto do_sku; |
| 1211 | } |
| 1212 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1213 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1214 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1215 | goto do_sku; |
| 1216 | |
| 1217 | nid = 0x1d; |
| 1218 | if (codec->vendor_id == 0x10ec0260) |
| 1219 | nid = 0x17; |
| 1220 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1221 | |
| 1222 | if (!(ass & 1)) { |
| 1223 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1224 | codec->chip_name, ass); |
| 1225 | return -1; |
| 1226 | } |
| 1227 | |
| 1228 | /* check sum */ |
| 1229 | tmp = 0; |
| 1230 | for (i = 1; i < 16; i++) { |
| 1231 | if ((ass >> i) & 1) |
| 1232 | tmp++; |
| 1233 | } |
| 1234 | if (((ass >> 16) & 0xf) != tmp) |
| 1235 | return -1; |
| 1236 | |
| 1237 | spec->cdefine.port_connectivity = ass >> 30; |
| 1238 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1239 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1240 | spec->cdefine.customization = ass >> 8; |
| 1241 | do_sku: |
| 1242 | spec->cdefine.sku_cfg = ass; |
| 1243 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1244 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1245 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1246 | spec->cdefine.override = ass & 0x1; |
| 1247 | |
| 1248 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1249 | nid, spec->cdefine.sku_cfg); |
| 1250 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1251 | spec->cdefine.port_connectivity); |
| 1252 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1253 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1254 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1255 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1256 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1257 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1258 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1259 | |
| 1260 | return 0; |
| 1261 | } |
| 1262 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1263 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1264 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1265 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1266 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1267 | } |
| 1268 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1269 | /* check subsystem ID and set up device-specific initialization; |
| 1270 | * return 1 if initialized, 0 if invalid SSID |
| 1271 | */ |
| 1272 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1273 | * 31 ~ 16 : Manufacture ID |
| 1274 | * 15 ~ 8 : SKU ID |
| 1275 | * 7 ~ 0 : Assembly ID |
| 1276 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1277 | */ |
| 1278 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1279 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1280 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1281 | { |
| 1282 | unsigned int ass, tmp, i; |
| 1283 | unsigned nid; |
| 1284 | struct alc_spec *spec = codec->spec; |
| 1285 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1286 | if (spec->cdefine.fixup) { |
| 1287 | ass = spec->cdefine.sku_cfg; |
| 1288 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1289 | return 0; |
| 1290 | goto do_sku; |
| 1291 | } |
| 1292 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1293 | ass = codec->subsystem_id & 0xffff; |
| 1294 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1295 | goto do_sku; |
| 1296 | |
| 1297 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1298 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1299 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1300 | * 29~21 : reserve |
| 1301 | * 20 : PCBEEP input |
| 1302 | * 19~16 : Check sum (15:1) |
| 1303 | * 15~1 : Custom |
| 1304 | * 0 : override |
| 1305 | */ |
| 1306 | nid = 0x1d; |
| 1307 | if (codec->vendor_id == 0x10ec0260) |
| 1308 | nid = 0x17; |
| 1309 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1310 | snd_printd("realtek: No valid SSID, " |
| 1311 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1312 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1313 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1314 | return 0; |
| 1315 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1316 | return 0; |
| 1317 | |
| 1318 | /* check sum */ |
| 1319 | tmp = 0; |
| 1320 | for (i = 1; i < 16; i++) { |
| 1321 | if ((ass >> i) & 1) |
| 1322 | tmp++; |
| 1323 | } |
| 1324 | if (((ass >> 16) & 0xf) != tmp) |
| 1325 | return 0; |
| 1326 | do_sku: |
| 1327 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1328 | ass & 0xffff, codec->vendor_id); |
| 1329 | /* |
| 1330 | * 0 : override |
| 1331 | * 1 : Swap Jack |
| 1332 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1333 | * 3~5 : External Amplifier control |
| 1334 | * 7~6 : Reserved |
| 1335 | */ |
| 1336 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1337 | switch (tmp) { |
| 1338 | case 1: |
| 1339 | spec->init_amp = ALC_INIT_GPIO1; |
| 1340 | break; |
| 1341 | case 3: |
| 1342 | spec->init_amp = ALC_INIT_GPIO2; |
| 1343 | break; |
| 1344 | case 7: |
| 1345 | spec->init_amp = ALC_INIT_GPIO3; |
| 1346 | break; |
| 1347 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1348 | default: |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1349 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1350 | break; |
| 1351 | } |
| 1352 | |
| 1353 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1354 | * when the external headphone out jack is plugged" |
| 1355 | */ |
| 1356 | if (!(ass & 0x8000)) |
| 1357 | return 1; |
| 1358 | /* |
| 1359 | * 10~8 : Jack location |
| 1360 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1361 | * 14~13: Resvered |
| 1362 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1363 | * when the external headphone out jack is plugged" |
| 1364 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1365 | if (!spec->autocfg.hp_pins[0] && |
| 1366 | !(spec->autocfg.line_out_pins[0] && |
| 1367 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1368 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1369 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1370 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1371 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1372 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1373 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1374 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1375 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1376 | else if (tmp == 3) |
| 1377 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1378 | else |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1379 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1380 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1381 | spec->autocfg.line_outs)) |
| 1382 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1383 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1384 | } |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1385 | return 1; |
| 1386 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1387 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1388 | /* Check the validity of ALC subsystem-id |
| 1389 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1390 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1391 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1392 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1393 | struct alc_spec *spec = codec->spec; |
| 1394 | snd_printd("realtek: " |
| 1395 | "Enable default setup for auto mode as fallback\n"); |
| 1396 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1397 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1398 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1399 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1400 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1401 | * COEF access helper functions |
| 1402 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1403 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1404 | unsigned int coef_idx) |
| 1405 | { |
| 1406 | unsigned int val; |
| 1407 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1408 | coef_idx); |
| 1409 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1410 | AC_VERB_GET_PROC_COEF, 0); |
| 1411 | return val; |
| 1412 | } |
| 1413 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1414 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1415 | unsigned int coef_val) |
| 1416 | { |
| 1417 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1418 | coef_idx); |
| 1419 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1420 | coef_val); |
| 1421 | } |
| 1422 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1423 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1424 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1425 | { |
| 1426 | struct alc_spec *spec = codec->spec; |
| 1427 | if (!spec->coef0) |
| 1428 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1429 | return spec->coef0; |
| 1430 | } |
| 1431 | |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1432 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 1433 | hda_nid_t pin, int pin_type, |
| 1434 | hda_nid_t dac); |
| 1435 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 1436 | bool is_digital); |
| 1437 | static bool add_new_out_path(struct hda_codec *codec, hda_nid_t pin, |
| 1438 | hda_nid_t dac); |
| 1439 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1440 | /* |
| 1441 | * Digital I/O handling |
| 1442 | */ |
| 1443 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1444 | /* set right pin controls for digital I/O */ |
| 1445 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1446 | { |
| 1447 | struct alc_spec *spec = codec->spec; |
| 1448 | int i; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1449 | hda_nid_t pin; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1450 | |
| 1451 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1452 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1453 | if (!pin) |
| 1454 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1455 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1456 | } |
| 1457 | pin = spec->autocfg.dig_in_pin; |
| 1458 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1459 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1463 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1464 | { |
| 1465 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1466 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1467 | hda_nid_t dig_nid; |
| 1468 | |
| 1469 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1470 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1471 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1472 | hda_nid_t pin = spec->autocfg.dig_out_pins[i]; |
| 1473 | dig_nid = alc_auto_look_for_dac(codec, pin, true); |
| 1474 | if (!dig_nid) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1475 | continue; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1476 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1477 | spec->multiout.dig_out_nid = dig_nid; |
| 1478 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1479 | } else { |
| 1480 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1481 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1482 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1483 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1484 | } |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1485 | add_new_out_path(codec, pin, dig_nid); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1486 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1487 | } |
| 1488 | |
| 1489 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1490 | dig_nid = codec->start_nid; |
| 1491 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1492 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1493 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1494 | continue; |
| 1495 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1496 | continue; |
| 1497 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1498 | continue; |
| 1499 | err = get_connection_index(codec, dig_nid, |
| 1500 | spec->autocfg.dig_in_pin); |
| 1501 | if (err >= 0) { |
| 1502 | spec->dig_in_nid = dig_nid; |
| 1503 | break; |
| 1504 | } |
| 1505 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1506 | } |
| 1507 | } |
| 1508 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1509 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1510 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1511 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1512 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1513 | struct snd_ctl_elem_info *uinfo) |
| 1514 | { |
| 1515 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1516 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1517 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1518 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1519 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1520 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1521 | if (spec->vol_in_capsrc) |
| 1522 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1523 | else |
| 1524 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1525 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1526 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1527 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1528 | return err; |
| 1529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1531 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1532 | unsigned int size, unsigned int __user *tlv) |
| 1533 | { |
| 1534 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1535 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1536 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1537 | int err; |
| 1538 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1539 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1540 | if (spec->vol_in_capsrc) |
| 1541 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1542 | else |
| 1543 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1544 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1545 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1546 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1547 | return err; |
| 1548 | } |
| 1549 | |
| 1550 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1551 | struct snd_ctl_elem_value *ucontrol); |
| 1552 | |
| 1553 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1554 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1555 | getput_call_t func, bool is_put) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1556 | { |
| 1557 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1558 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1559 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1560 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1561 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1562 | if (is_put && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1563 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1564 | kcontrol->private_value = |
| 1565 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1566 | 3, 0, HDA_INPUT); |
| 1567 | err = func(kcontrol, ucontrol); |
| 1568 | if (err < 0) |
| 1569 | goto error; |
| 1570 | } |
| 1571 | } else { |
| 1572 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1573 | if (spec->vol_in_capsrc) |
| 1574 | kcontrol->private_value = |
| 1575 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1576 | 3, 0, HDA_OUTPUT); |
| 1577 | else |
| 1578 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1579 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1580 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1581 | err = func(kcontrol, ucontrol); |
| 1582 | } |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1583 | if (err >= 0 && is_put) |
| 1584 | alc_inv_dmic_sync(codec, false); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1585 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1586 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1587 | return err; |
| 1588 | } |
| 1589 | |
| 1590 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1591 | struct snd_ctl_elem_value *ucontrol) |
| 1592 | { |
| 1593 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1594 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1595 | } |
| 1596 | |
| 1597 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1598 | struct snd_ctl_elem_value *ucontrol) |
| 1599 | { |
| 1600 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1601 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1602 | } |
| 1603 | |
| 1604 | /* capture mixer elements */ |
| 1605 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1606 | |
| 1607 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1608 | struct snd_ctl_elem_value *ucontrol) |
| 1609 | { |
| 1610 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1611 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1612 | } |
| 1613 | |
| 1614 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1615 | struct snd_ctl_elem_value *ucontrol) |
| 1616 | { |
| 1617 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1618 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1619 | } |
| 1620 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1621 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1622 | { \ |
| 1623 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1624 | .name = "Capture Switch", \ |
| 1625 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1626 | .count = num, \ |
| 1627 | .info = alc_cap_sw_info, \ |
| 1628 | .get = alc_cap_sw_get, \ |
| 1629 | .put = alc_cap_sw_put, \ |
| 1630 | }, \ |
| 1631 | { \ |
| 1632 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1633 | .name = "Capture Volume", \ |
| 1634 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1635 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1636 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1637 | .count = num, \ |
| 1638 | .info = alc_cap_vol_info, \ |
| 1639 | .get = alc_cap_vol_get, \ |
| 1640 | .put = alc_cap_vol_put, \ |
| 1641 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1642 | } |
| 1643 | |
| 1644 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1645 | { \ |
| 1646 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1647 | /* .name = "Capture Source", */ \ |
| 1648 | .name = "Input Source", \ |
| 1649 | .count = num, \ |
| 1650 | .info = alc_mux_enum_info, \ |
| 1651 | .get = alc_mux_enum_get, \ |
| 1652 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1653 | } |
| 1654 | |
| 1655 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1656 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1657 | _DEFINE_CAPMIX(num), \ |
| 1658 | _DEFINE_CAPSRC(num), \ |
| 1659 | { } /* end */ \ |
| 1660 | } |
| 1661 | |
| 1662 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1663 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1664 | _DEFINE_CAPMIX(num), \ |
| 1665 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1666 | } |
| 1667 | |
| 1668 | /* up to three ADCs */ |
| 1669 | DEFINE_CAPMIX(1); |
| 1670 | DEFINE_CAPMIX(2); |
| 1671 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1672 | DEFINE_CAPMIX_NOSRC(1); |
| 1673 | DEFINE_CAPMIX_NOSRC(2); |
| 1674 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1675 | |
| 1676 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1677 | * Inverted digital-mic handling |
| 1678 | * |
| 1679 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1680 | * gives the additional mute only to the right channel of the digital mic |
| 1681 | * capture stream. This is a workaround for avoiding the almost silence |
| 1682 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1683 | * digital mic unit. |
| 1684 | * |
| 1685 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1686 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1687 | * without caching so that the cache can still keep the original value. |
| 1688 | * The cached value is then restored when the flag is set off or any other |
| 1689 | * than d-mic is used as the current input source. |
| 1690 | */ |
| 1691 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1692 | { |
| 1693 | struct alc_spec *spec = codec->spec; |
| 1694 | int i; |
| 1695 | |
| 1696 | if (!spec->inv_dmic_fixup) |
| 1697 | return; |
| 1698 | if (!spec->inv_dmic_muted && !force) |
| 1699 | return; |
| 1700 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1701 | int src = spec->dyn_adc_switch ? 0 : i; |
| 1702 | bool dmic_fixup = false; |
| 1703 | hda_nid_t nid; |
| 1704 | int parm, dir, v; |
| 1705 | |
| 1706 | if (spec->inv_dmic_muted && |
| 1707 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1708 | dmic_fixup = true; |
| 1709 | if (!dmic_fixup && !force) |
| 1710 | continue; |
| 1711 | if (spec->vol_in_capsrc) { |
| 1712 | nid = spec->capsrc_nids[i]; |
| 1713 | parm = AC_AMP_SET_RIGHT | AC_AMP_SET_OUTPUT; |
| 1714 | dir = HDA_OUTPUT; |
| 1715 | } else { |
| 1716 | nid = spec->adc_nids[i]; |
| 1717 | parm = AC_AMP_SET_RIGHT | AC_AMP_SET_INPUT; |
| 1718 | dir = HDA_INPUT; |
| 1719 | } |
| 1720 | /* we care only right channel */ |
| 1721 | v = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1722 | if (v & 0x80) /* if already muted, we don't need to touch */ |
| 1723 | continue; |
| 1724 | if (dmic_fixup) /* add mute for d-mic */ |
| 1725 | v |= 0x80; |
| 1726 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1727 | parm | v); |
| 1728 | } |
| 1729 | } |
| 1730 | |
| 1731 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1732 | struct snd_ctl_elem_value *ucontrol) |
| 1733 | { |
| 1734 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1735 | struct alc_spec *spec = codec->spec; |
| 1736 | |
| 1737 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1738 | return 0; |
| 1739 | } |
| 1740 | |
| 1741 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1742 | struct snd_ctl_elem_value *ucontrol) |
| 1743 | { |
| 1744 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1745 | struct alc_spec *spec = codec->spec; |
| 1746 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1747 | |
| 1748 | if (val == spec->inv_dmic_muted) |
| 1749 | return 0; |
| 1750 | spec->inv_dmic_muted = val; |
| 1751 | alc_inv_dmic_sync(codec, true); |
| 1752 | return 0; |
| 1753 | } |
| 1754 | |
| 1755 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1756 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1757 | .info = snd_ctl_boolean_mono_info, |
| 1758 | .get = alc_inv_dmic_sw_get, |
| 1759 | .put = alc_inv_dmic_sw_put, |
| 1760 | }; |
| 1761 | |
| 1762 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1763 | { |
| 1764 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 1765 | |
| 1766 | if (!alc_kcontrol_new(spec, "Inverted Internal Mic Capture Switch", |
| 1767 | &alc_inv_dmic_sw)) |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1768 | return -ENOMEM; |
| 1769 | spec->inv_dmic_fixup = 1; |
| 1770 | spec->inv_dmic_muted = 0; |
| 1771 | spec->inv_dmic_pin = nid; |
| 1772 | return 0; |
| 1773 | } |
| 1774 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1775 | /* typically the digital mic is put at node 0x12 */ |
| 1776 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1777 | const struct alc_fixup *fix, int action) |
| 1778 | { |
| 1779 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1780 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1781 | } |
| 1782 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1783 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1784 | * virtual master controls |
| 1785 | */ |
| 1786 | |
| 1787 | /* |
| 1788 | * slave controls for virtual master |
| 1789 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1790 | static const char * const alc_slave_pfxs[] = { |
| 1791 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1792 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1793 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1794 | NULL, |
| 1795 | }; |
| 1796 | |
| 1797 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1798 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1800 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1801 | #define NID_MAPPING (-1) |
| 1802 | |
| 1803 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1804 | #define SUBDEV_HP_ (1 << 6) |
| 1805 | #define SUBDEV_LINE_ (2 << 6) |
| 1806 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1807 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1808 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1809 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1810 | static void alc_free_kctls(struct hda_codec *codec); |
| 1811 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1812 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1813 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1814 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1815 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1816 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1817 | { } /* end */ |
| 1818 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1819 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1820 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1821 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | { |
| 1823 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1824 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1825 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1826 | int i, j, err; |
| 1827 | unsigned int u; |
| 1828 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | |
| 1830 | for (i = 0; i < spec->num_mixers; i++) { |
| 1831 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1832 | if (err < 0) |
| 1833 | return err; |
| 1834 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1835 | if (spec->cap_mixer) { |
| 1836 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1837 | if (err < 0) |
| 1838 | return err; |
| 1839 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1841 | err = snd_hda_create_dig_out_ctls(codec, |
| 1842 | spec->multiout.dig_out_nid, |
| 1843 | spec->multiout.dig_out_nid, |
| 1844 | spec->pcm_rec[1].pcm_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1845 | if (err < 0) |
| 1846 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1847 | if (!spec->no_analog) { |
| 1848 | err = snd_hda_create_spdif_share_sw(codec, |
| 1849 | &spec->multiout); |
| 1850 | if (err < 0) |
| 1851 | return err; |
| 1852 | spec->multiout.share_spdif = 1; |
| 1853 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1854 | } |
| 1855 | if (spec->dig_in_nid) { |
| 1856 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1857 | if (err < 0) |
| 1858 | return err; |
| 1859 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1860 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1861 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1862 | /* create beep controls if needed */ |
| 1863 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1864 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1865 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1866 | struct snd_kcontrol *kctl; |
| 1867 | kctl = snd_ctl_new1(knew, codec); |
| 1868 | if (!kctl) |
| 1869 | return -ENOMEM; |
| 1870 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1871 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1872 | if (err < 0) |
| 1873 | return err; |
| 1874 | } |
| 1875 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1876 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1877 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1878 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1879 | if (!spec->no_analog && |
| 1880 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1881 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1882 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1883 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1884 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1885 | vmaster_tlv, alc_slave_pfxs, |
| 1886 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1887 | if (err < 0) |
| 1888 | return err; |
| 1889 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1890 | if (!spec->no_analog && |
| 1891 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1892 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1893 | NULL, alc_slave_pfxs, |
| 1894 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1895 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1896 | if (err < 0) |
| 1897 | return err; |
| 1898 | } |
| 1899 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1900 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1901 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1902 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1903 | if (!kctl) |
| 1904 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1905 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1906 | err = snd_hda_add_nid(codec, kctl, i, |
| 1907 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1908 | if (err < 0) |
| 1909 | return err; |
| 1910 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1911 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1912 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1913 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1914 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1915 | if (kname && strcmp(knew->name, kname) == 0) |
| 1916 | continue; |
| 1917 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1918 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1919 | err = snd_hda_add_nid(codec, kctl, i, |
| 1920 | spec->adc_nids[i]); |
| 1921 | if (err < 0) |
| 1922 | return err; |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | |
| 1927 | /* other nid->control mapping */ |
| 1928 | for (i = 0; i < spec->num_mixers; i++) { |
| 1929 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1930 | if (knew->iface != NID_MAPPING) |
| 1931 | continue; |
| 1932 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1933 | if (kctl == NULL) |
| 1934 | continue; |
| 1935 | u = knew->subdevice; |
| 1936 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1937 | nid = u & 0x3f; |
| 1938 | if (nid == 0) |
| 1939 | continue; |
| 1940 | switch (u & 0xc0) { |
| 1941 | case SUBDEV_SPEAKER_: |
| 1942 | nid = spec->autocfg.speaker_pins[nid]; |
| 1943 | break; |
| 1944 | case SUBDEV_LINE_: |
| 1945 | nid = spec->autocfg.line_out_pins[nid]; |
| 1946 | break; |
| 1947 | case SUBDEV_HP_: |
| 1948 | nid = spec->autocfg.hp_pins[nid]; |
| 1949 | break; |
| 1950 | default: |
| 1951 | continue; |
| 1952 | } |
| 1953 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1954 | if (err < 0) |
| 1955 | return err; |
| 1956 | } |
| 1957 | u = knew->private_value; |
| 1958 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1959 | nid = u & 0xff; |
| 1960 | if (nid == 0) |
| 1961 | continue; |
| 1962 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1963 | if (err < 0) |
| 1964 | return err; |
| 1965 | } |
| 1966 | } |
| 1967 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1968 | |
| 1969 | alc_free_kctls(codec); /* no longer needed */ |
| 1970 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1971 | return 0; |
| 1972 | } |
| 1973 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1974 | static int alc_build_jacks(struct hda_codec *codec) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1975 | { |
| 1976 | struct alc_spec *spec = codec->spec; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1977 | |
| 1978 | if (spec->shared_mic_hp) { |
| 1979 | int err; |
| 1980 | int nid = spec->autocfg.inputs[1].pin; |
| 1981 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1982 | if (err < 0) |
| 1983 | return err; |
| 1984 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1985 | if (err < 0) |
| 1986 | return err; |
| 1987 | } |
| 1988 | |
| 1989 | return snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1990 | } |
| 1991 | |
| 1992 | static int alc_build_controls(struct hda_codec *codec) |
| 1993 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1994 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1995 | if (err < 0) |
| 1996 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1997 | |
| 1998 | err = alc_build_jacks(codec); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1999 | if (err < 0) |
| 2000 | return err; |
| 2001 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 2002 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | } |
| 2004 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2005 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2006 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2007 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2008 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2009 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2010 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2011 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2012 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2013 | static int alc_init(struct hda_codec *codec) |
| 2014 | { |
| 2015 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2016 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 2017 | if (spec->init_hook) |
| 2018 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 2019 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2020 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2021 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2022 | |
Takashi Iwai | 2e8b2b2 | 2012-06-13 16:47:32 +0200 | [diff] [blame] | 2023 | snd_hda_gen_apply_verbs(codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2024 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2025 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2026 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2027 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2028 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2029 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | return 0; |
| 2031 | } |
| 2032 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2033 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2034 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2035 | { |
| 2036 | struct alc_spec *spec = codec->spec; |
| 2037 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2038 | } |
| 2039 | #endif |
| 2040 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2041 | /* |
| 2042 | * Analog playback callbacks |
| 2043 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2044 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2045 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2046 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | { |
| 2048 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2049 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2050 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2051 | } |
| 2052 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2053 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | struct hda_codec *codec, |
| 2055 | unsigned int stream_tag, |
| 2056 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2057 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | { |
| 2059 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2060 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2061 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | } |
| 2063 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2064 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2066 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | { |
| 2068 | struct alc_spec *spec = codec->spec; |
| 2069 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2070 | } |
| 2071 | |
| 2072 | /* |
| 2073 | * Digital out |
| 2074 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2075 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2077 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | { |
| 2079 | struct alc_spec *spec = codec->spec; |
| 2080 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2081 | } |
| 2082 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2083 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2084 | struct hda_codec *codec, |
| 2085 | unsigned int stream_tag, |
| 2086 | unsigned int format, |
| 2087 | struct snd_pcm_substream *substream) |
| 2088 | { |
| 2089 | struct alc_spec *spec = codec->spec; |
| 2090 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2091 | stream_tag, format, substream); |
| 2092 | } |
| 2093 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2094 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2095 | struct hda_codec *codec, |
| 2096 | struct snd_pcm_substream *substream) |
| 2097 | { |
| 2098 | struct alc_spec *spec = codec->spec; |
| 2099 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2100 | } |
| 2101 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2102 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2104 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | { |
| 2106 | struct alc_spec *spec = codec->spec; |
| 2107 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2108 | } |
| 2109 | |
| 2110 | /* |
| 2111 | * Analog capture |
| 2112 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2113 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | struct hda_codec *codec, |
| 2115 | unsigned int stream_tag, |
| 2116 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2117 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | { |
| 2119 | struct alc_spec *spec = codec->spec; |
| 2120 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2121 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | stream_tag, 0, format); |
| 2123 | return 0; |
| 2124 | } |
| 2125 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2126 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2128 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | { |
| 2130 | struct alc_spec *spec = codec->spec; |
| 2131 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2132 | snd_hda_codec_cleanup_stream(codec, |
| 2133 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | return 0; |
| 2135 | } |
| 2136 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2137 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2138 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2139 | struct hda_codec *codec, |
| 2140 | unsigned int stream_tag, |
| 2141 | unsigned int format, |
| 2142 | struct snd_pcm_substream *substream) |
| 2143 | { |
| 2144 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2145 | 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] | 2146 | spec->cur_adc_stream_tag = stream_tag; |
| 2147 | spec->cur_adc_format = format; |
| 2148 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2149 | return 0; |
| 2150 | } |
| 2151 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2152 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2153 | struct hda_codec *codec, |
| 2154 | struct snd_pcm_substream *substream) |
| 2155 | { |
| 2156 | struct alc_spec *spec = codec->spec; |
| 2157 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2158 | spec->cur_adc = 0; |
| 2159 | return 0; |
| 2160 | } |
| 2161 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2162 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2163 | .substreams = 1, |
| 2164 | .channels_min = 2, |
| 2165 | .channels_max = 2, |
| 2166 | .nid = 0, /* fill later */ |
| 2167 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2168 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2169 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2170 | }, |
| 2171 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | |
| 2173 | /* |
| 2174 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2175 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | .substreams = 1, |
| 2177 | .channels_min = 2, |
| 2178 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2179 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2181 | .open = alc_playback_pcm_open, |
| 2182 | .prepare = alc_playback_pcm_prepare, |
| 2183 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | }, |
| 2185 | }; |
| 2186 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2187 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2188 | .substreams = 1, |
| 2189 | .channels_min = 2, |
| 2190 | .channels_max = 2, |
| 2191 | /* NID is set in alc_build_pcms */ |
| 2192 | }; |
| 2193 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2194 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2195 | .substreams = 1, |
| 2196 | .channels_min = 2, |
| 2197 | .channels_max = 2, |
| 2198 | /* NID is set in alc_build_pcms */ |
| 2199 | }; |
| 2200 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2201 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2202 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | .channels_min = 2, |
| 2204 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2205 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2207 | .prepare = alc_alt_capture_pcm_prepare, |
| 2208 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | }, |
| 2210 | }; |
| 2211 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2212 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | .substreams = 1, |
| 2214 | .channels_min = 2, |
| 2215 | .channels_max = 2, |
| 2216 | /* NID is set in alc_build_pcms */ |
| 2217 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2218 | .open = alc_dig_playback_pcm_open, |
| 2219 | .close = alc_dig_playback_pcm_close, |
| 2220 | .prepare = alc_dig_playback_pcm_prepare, |
| 2221 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2222 | }, |
| 2223 | }; |
| 2224 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2225 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | .substreams = 1, |
| 2227 | .channels_min = 2, |
| 2228 | .channels_max = 2, |
| 2229 | /* NID is set in alc_build_pcms */ |
| 2230 | }; |
| 2231 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2232 | /* 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] | 2233 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2234 | .substreams = 0, |
| 2235 | .channels_min = 0, |
| 2236 | .channels_max = 0, |
| 2237 | }; |
| 2238 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | static int alc_build_pcms(struct hda_codec *codec) |
| 2240 | { |
| 2241 | struct alc_spec *spec = codec->spec; |
| 2242 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2243 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2244 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | int i; |
| 2246 | |
| 2247 | codec->num_pcms = 1; |
| 2248 | codec->pcm_info = info; |
| 2249 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2250 | if (spec->no_analog) |
| 2251 | goto skip_analog; |
| 2252 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2253 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2254 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2256 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2257 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2258 | p = spec->stream_analog_playback; |
| 2259 | if (!p) |
| 2260 | p = &alc_pcm_analog_playback; |
| 2261 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2262 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 2263 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 2264 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 2265 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 2266 | spec->autocfg.line_outs == 2) |
| 2267 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 2268 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2269 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2270 | if (spec->adc_nids) { |
| 2271 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2272 | if (!p) { |
| 2273 | if (spec->dyn_adc_switch) |
| 2274 | p = &dyn_adc_pcm_analog_capture; |
| 2275 | else |
| 2276 | p = &alc_pcm_analog_capture; |
| 2277 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2278 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2279 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2280 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2282 | if (spec->channel_mode) { |
| 2283 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2284 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2285 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2286 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2287 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | } |
| 2289 | } |
| 2290 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2291 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2292 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2294 | snprintf(spec->stream_name_digital, |
| 2295 | sizeof(spec->stream_name_digital), |
| 2296 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2297 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2298 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2299 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2300 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2301 | if (spec->dig_out_type) |
| 2302 | info->pcm_type = spec->dig_out_type; |
| 2303 | else |
| 2304 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2305 | if (spec->multiout.dig_out_nid) { |
| 2306 | p = spec->stream_digital_playback; |
| 2307 | if (!p) |
| 2308 | p = &alc_pcm_digital_playback; |
| 2309 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2310 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2311 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2312 | if (spec->dig_in_nid) { |
| 2313 | p = spec->stream_digital_capture; |
| 2314 | if (!p) |
| 2315 | p = &alc_pcm_digital_capture; |
| 2316 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2318 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2319 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2320 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | } |
| 2322 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2323 | if (spec->no_analog) |
| 2324 | return 0; |
| 2325 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2326 | /* If the use of more than one ADC is requested for the current |
| 2327 | * model, configure a second analog capture-only PCM. |
| 2328 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2329 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2330 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2331 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2332 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2333 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2334 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2335 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2336 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2337 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2338 | p = spec->stream_analog_alt_playback; |
| 2339 | if (!p) |
| 2340 | p = &alc_pcm_analog_alt_playback; |
| 2341 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2342 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2343 | spec->alt_dac_nid; |
| 2344 | } else { |
| 2345 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2346 | alc_pcm_null_stream; |
| 2347 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2348 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2349 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2350 | p = spec->stream_analog_alt_capture; |
| 2351 | if (!p) |
| 2352 | p = &alc_pcm_analog_alt_capture; |
| 2353 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2354 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2355 | spec->adc_nids[1]; |
| 2356 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2357 | spec->num_adc_nids - 1; |
| 2358 | } else { |
| 2359 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2360 | alc_pcm_null_stream; |
| 2361 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2362 | } |
| 2363 | } |
| 2364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | return 0; |
| 2366 | } |
| 2367 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2368 | static inline void alc_shutup(struct hda_codec *codec) |
| 2369 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2370 | struct alc_spec *spec = codec->spec; |
| 2371 | |
| 2372 | if (spec && spec->shutup) |
| 2373 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2374 | snd_hda_shutup_pins(codec); |
| 2375 | } |
| 2376 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2377 | static void alc_free_kctls(struct hda_codec *codec) |
| 2378 | { |
| 2379 | struct alc_spec *spec = codec->spec; |
| 2380 | |
| 2381 | if (spec->kctls.list) { |
| 2382 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2383 | int i; |
| 2384 | for (i = 0; i < spec->kctls.used; i++) |
| 2385 | kfree(kctl[i].name); |
| 2386 | } |
| 2387 | snd_array_free(&spec->kctls); |
| 2388 | } |
| 2389 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2390 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2391 | { |
| 2392 | struct alc_spec *spec = codec->spec; |
| 2393 | if (spec->bind_ctls.list) { |
| 2394 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2395 | int i; |
| 2396 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2397 | kfree(ctl[i]); |
| 2398 | } |
| 2399 | snd_array_free(&spec->bind_ctls); |
| 2400 | } |
| 2401 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2402 | static void alc_free(struct hda_codec *codec) |
| 2403 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2404 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2405 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2406 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2407 | return; |
| 2408 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2409 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2410 | alc_free_bind_ctls(codec); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2411 | snd_array_free(&spec->paths); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 2412 | snd_hda_gen_free(&spec->gen); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2413 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2414 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2415 | } |
| 2416 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2417 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2418 | static void alc_power_eapd(struct hda_codec *codec) |
| 2419 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2420 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2421 | } |
| 2422 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2423 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2424 | { |
| 2425 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2426 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2427 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2428 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2429 | return 0; |
| 2430 | } |
| 2431 | #endif |
| 2432 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2433 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2434 | static int alc_resume(struct hda_codec *codec) |
| 2435 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2436 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2437 | codec->patch_ops.init(codec); |
| 2438 | snd_hda_codec_resume_amp(codec); |
| 2439 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2440 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2441 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2442 | return 0; |
| 2443 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2444 | #endif |
| 2445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2446 | /* |
| 2447 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2448 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | .build_controls = alc_build_controls, |
| 2450 | .build_pcms = alc_build_pcms, |
| 2451 | .init = alc_init, |
| 2452 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2453 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2454 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2455 | .resume = alc_resume, |
| 2456 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2457 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2458 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2459 | .check_power_status = alc_check_power_status, |
| 2460 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2461 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2462 | }; |
| 2463 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2464 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2465 | /* replace the codec chip_name with the given string */ |
| 2466 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2467 | { |
| 2468 | kfree(codec->chip_name); |
| 2469 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2470 | if (!codec->chip_name) { |
| 2471 | alc_free(codec); |
| 2472 | return -ENOMEM; |
| 2473 | } |
| 2474 | return 0; |
| 2475 | } |
| 2476 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2477 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2478 | * Rename codecs appropriately from COEF value |
| 2479 | */ |
| 2480 | struct alc_codec_rename_table { |
| 2481 | unsigned int vendor_id; |
| 2482 | unsigned short coef_mask; |
| 2483 | unsigned short coef_bits; |
| 2484 | const char *name; |
| 2485 | }; |
| 2486 | |
| 2487 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2488 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2489 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2490 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2491 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2492 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2493 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2494 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2495 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2496 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2497 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2498 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2499 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2500 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2501 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2502 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2503 | { } /* terminator */ |
| 2504 | }; |
| 2505 | |
| 2506 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2507 | { |
| 2508 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2509 | |
| 2510 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2511 | if (p->vendor_id != codec->vendor_id) |
| 2512 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2513 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2514 | return alc_codec_rename(codec, p->name); |
| 2515 | } |
| 2516 | return 0; |
| 2517 | } |
| 2518 | |
| 2519 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2520 | * Automatic parse of I/O pins from the BIOS configuration |
| 2521 | */ |
| 2522 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2523 | enum { |
| 2524 | ALC_CTL_WIDGET_VOL, |
| 2525 | ALC_CTL_WIDGET_MUTE, |
| 2526 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2527 | ALC_CTL_BIND_VOL, |
| 2528 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2529 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2530 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2531 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2532 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2533 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2534 | HDA_BIND_VOL(NULL, 0), |
| 2535 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2536 | }; |
| 2537 | |
| 2538 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2539 | 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] | 2540 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2541 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2542 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2543 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 2544 | knew = alc_kcontrol_new(spec, name, &alc_control_templates[type]); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2545 | if (!knew) |
| 2546 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2547 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2548 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2549 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2550 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2551 | return 0; |
| 2552 | } |
| 2553 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2554 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2555 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2556 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2557 | { |
| 2558 | char name[32]; |
| 2559 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2560 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2561 | } |
| 2562 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2563 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2564 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2565 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2566 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2567 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2568 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2569 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2570 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2571 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2572 | static const char * const channel_name[4] = { |
| 2573 | "Front", "Surround", "CLFE", "Side" |
| 2574 | }; |
| 2575 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2576 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2577 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2578 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2579 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2580 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2581 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2582 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2583 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2584 | return "Master"; |
| 2585 | |
| 2586 | switch (cfg->line_out_type) { |
| 2587 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2588 | if (cfg->line_outs == 1) |
| 2589 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2590 | if (cfg->line_outs == 2) |
| 2591 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2592 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2593 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2594 | /* for multi-io case, only the primary out */ |
| 2595 | if (ch && spec->multi_ios) |
| 2596 | break; |
| 2597 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2598 | return "Headphone"; |
| 2599 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2600 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2601 | return "PCM"; |
| 2602 | break; |
| 2603 | } |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2604 | if (ch >= ARRAY_SIZE(channel_name)) { |
| 2605 | snd_BUG(); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2606 | return "PCM"; |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2607 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2608 | |
| 2609 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2610 | } |
| 2611 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2612 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2613 | hda_nid_t to_nid, int with_aa_mix, |
| 2614 | struct nid_path *path); |
| 2615 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2616 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2617 | /* add the powersave loopback-list entry */ |
| 2618 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2619 | { |
| 2620 | struct hda_amp_list *list; |
| 2621 | |
| 2622 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2623 | return; |
| 2624 | list = spec->loopback_list + spec->num_loopbacks; |
| 2625 | list->nid = mix; |
| 2626 | list->dir = HDA_INPUT; |
| 2627 | list->idx = idx; |
| 2628 | spec->num_loopbacks++; |
| 2629 | spec->loopback.amplist = spec->loopback_list; |
| 2630 | } |
| 2631 | #else |
| 2632 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2633 | #endif |
| 2634 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2635 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2636 | 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] | 2637 | const char *ctlname, int ctlidx, |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2638 | hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2639 | { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2640 | struct alc_spec *spec = codec->spec; |
| 2641 | struct nid_path *path; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2642 | unsigned int val; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2643 | int err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2644 | |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2645 | if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && |
| 2646 | !nid_has_mute(codec, mix_nid, HDA_INPUT)) |
| 2647 | return 0; /* no need for analog loopback */ |
| 2648 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2649 | path = snd_array_new(&spec->paths); |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2650 | if (!path) |
| 2651 | return -ENOMEM; |
| 2652 | memset(path, 0, sizeof(*path)); |
| 2653 | if (!parse_nid_path(codec, pin, mix_nid, 2, path)) |
| 2654 | return -EINVAL; |
| 2655 | |
| 2656 | idx = path->idx[path->depth - 1]; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2657 | if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2658 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2659 | 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] | 2660 | if (err < 0) |
| 2661 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2662 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2663 | } |
| 2664 | |
| 2665 | if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2666 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2667 | 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] | 2668 | if (err < 0) |
| 2669 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2670 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2671 | } |
| 2672 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2673 | path->active = true; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2674 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2675 | return 0; |
| 2676 | } |
| 2677 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2678 | static int new_capture_source(struct hda_codec *codec, int adc_idx, |
| 2679 | hda_nid_t pin, int idx, const char *label) |
| 2680 | { |
| 2681 | struct alc_spec *spec = codec->spec; |
| 2682 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 2683 | struct nid_path *path; |
| 2684 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2685 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2686 | if (!path) |
| 2687 | return -ENOMEM; |
| 2688 | memset(path, 0, sizeof(*path)); |
| 2689 | if (!parse_nid_path(codec, pin, spec->adc_nids[adc_idx], 2, path)) { |
| 2690 | snd_printd(KERN_ERR "invalid input path 0x%x -> 0x%x\n", |
| 2691 | pin, spec->adc_nids[adc_idx]); |
| 2692 | return -EINVAL; |
| 2693 | } |
| 2694 | |
| 2695 | spec->imux_pins[imux->num_items] = pin; |
| 2696 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2697 | return 0; |
| 2698 | } |
| 2699 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2700 | 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] | 2701 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2702 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2703 | return (pincap & AC_PINCAP_IN) != 0; |
| 2704 | } |
| 2705 | |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2706 | /* check whether the given two widgets can be connected */ |
| 2707 | static bool is_reachable_path(struct hda_codec *codec, |
| 2708 | hda_nid_t from_nid, hda_nid_t to_nid) |
| 2709 | { |
| 2710 | if (!from_nid || !to_nid) |
| 2711 | return false; |
| 2712 | return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; |
| 2713 | } |
| 2714 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2715 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2716 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2717 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2718 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2719 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2720 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2721 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2722 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2723 | int i, nums = 0; |
| 2724 | |
| 2725 | nid = codec->start_nid; |
| 2726 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2727 | hda_nid_t src; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2728 | unsigned int caps = get_wcaps(codec, nid); |
| 2729 | int type = get_wcaps_type(caps); |
| 2730 | |
| 2731 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2732 | continue; |
| 2733 | adc_nids[nums] = nid; |
| 2734 | cap_nids[nums] = nid; |
| 2735 | src = nid; |
| 2736 | for (;;) { |
| 2737 | int n; |
| 2738 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2739 | if (type == AC_WID_PIN) |
| 2740 | break; |
| 2741 | if (type == AC_WID_AUD_SEL) { |
| 2742 | cap_nids[nums] = src; |
| 2743 | break; |
| 2744 | } |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2745 | n = snd_hda_get_num_conns(codec, src); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2746 | if (n > 1) { |
| 2747 | cap_nids[nums] = src; |
| 2748 | break; |
| 2749 | } else if (n != 1) |
| 2750 | break; |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2751 | if (snd_hda_get_connections(codec, src, &src, 1) != 1) |
| 2752 | break; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2753 | } |
| 2754 | if (++nums >= max_nums) |
| 2755 | break; |
| 2756 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2757 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2758 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2759 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2760 | return nums; |
| 2761 | } |
| 2762 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2763 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2764 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2765 | { |
| 2766 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2767 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2768 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2769 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2770 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2771 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2772 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2773 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2774 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2775 | if (num_adcs < 0) |
| 2776 | return 0; |
| 2777 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2778 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2779 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2780 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2781 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2782 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2783 | if (!alc_is_input_pin(codec, pin)) |
| 2784 | continue; |
| 2785 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2786 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2787 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2788 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2789 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2790 | type_idx++; |
| 2791 | else |
| 2792 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2793 | prev_label = label; |
| 2794 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2795 | if (mixer) { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2796 | if (is_reachable_path(codec, pin, mixer)) { |
| 2797 | err = new_analog_input(codec, pin, |
| 2798 | label, type_idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2799 | if (err < 0) |
| 2800 | return err; |
| 2801 | } |
| 2802 | } |
| 2803 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2804 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2805 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2806 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2807 | if (idx >= 0) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2808 | err = new_capture_source(codec, c, pin, idx, label); |
| 2809 | if (err < 0) |
| 2810 | return err; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2811 | break; |
| 2812 | } |
| 2813 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2814 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2815 | |
| 2816 | spec->num_mux_defs = 1; |
| 2817 | spec->input_mux = imux; |
| 2818 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2819 | return 0; |
| 2820 | } |
| 2821 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2822 | /* create a shared input with the headphone out */ |
| 2823 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2824 | { |
| 2825 | struct alc_spec *spec = codec->spec; |
| 2826 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2827 | unsigned int defcfg; |
| 2828 | hda_nid_t nid; |
| 2829 | |
| 2830 | /* only one internal input pin? */ |
| 2831 | if (cfg->num_inputs != 1) |
| 2832 | return 0; |
| 2833 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2834 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2835 | return 0; |
| 2836 | |
| 2837 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2838 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2839 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2840 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2841 | else |
| 2842 | return 0; /* both not available */ |
| 2843 | |
| 2844 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2845 | return 0; /* no input */ |
| 2846 | |
| 2847 | cfg->inputs[1].pin = nid; |
| 2848 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2849 | cfg->num_inputs = 2; |
| 2850 | spec->shared_mic_hp = 1; |
| 2851 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2852 | return 0; |
| 2853 | } |
| 2854 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2855 | static struct nid_path * |
| 2856 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid); |
| 2857 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 2858 | bool enable); |
| 2859 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2860 | static int get_pin_type(int line_out_type) |
| 2861 | { |
| 2862 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2863 | return PIN_HP; |
| 2864 | else |
| 2865 | return PIN_OUT; |
| 2866 | } |
| 2867 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2868 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2869 | { |
| 2870 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2871 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2872 | int i; |
| 2873 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2874 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2875 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2876 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2877 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2878 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2879 | snd_hda_codec_write(codec, nid, 0, |
| 2880 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2881 | AMP_OUT_MUTE); |
| 2882 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2883 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame^] | 2884 | /* mute loopback inputs */ |
| 2885 | if (spec->mixer_nid) { |
| 2886 | struct nid_path *path; |
| 2887 | path = get_nid_path(codec, nid, spec->mixer_nid); |
| 2888 | if (path) |
| 2889 | activate_path(codec, path, path->active); |
| 2890 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2891 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2892 | } |
| 2893 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2894 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2895 | { |
| 2896 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2897 | int i; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2898 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2899 | for (i = 0; i < spec->paths.used; i++) { |
| 2900 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2901 | if (path->path[0] == nid) |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2902 | return true; |
| 2903 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2904 | return false; |
| 2905 | } |
| 2906 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2907 | /* look for an empty DAC slot */ |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2908 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2909 | bool is_digital) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2910 | { |
| 2911 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2912 | bool cap_digital; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2913 | int i; |
| 2914 | |
| 2915 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2916 | hda_nid_t nid = spec->all_dacs[i]; |
| 2917 | if (!nid || alc_is_dac_already_used(codec, nid)) |
| 2918 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2919 | cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); |
| 2920 | if (is_digital != cap_digital) |
| 2921 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2922 | if (is_reachable_path(codec, nid, pin)) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2923 | return nid; |
| 2924 | } |
| 2925 | return 0; |
| 2926 | } |
| 2927 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2928 | /* called recursively */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2929 | static bool __parse_nid_path(struct hda_codec *codec, |
| 2930 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2931 | int with_aa_mix, struct nid_path *path, int depth) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2932 | { |
| 2933 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2934 | hda_nid_t conn[16]; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2935 | int i, nums; |
| 2936 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2937 | if (to_nid == spec->mixer_nid) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2938 | if (!with_aa_mix) |
| 2939 | return false; |
| 2940 | with_aa_mix = 2; /* mark aa-mix is included */ |
| 2941 | } |
| 2942 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2943 | nums = snd_hda_get_connections(codec, to_nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2944 | for (i = 0; i < nums; i++) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2945 | if (conn[i] != from_nid) { |
| 2946 | /* special case: when from_nid is 0, |
| 2947 | * try to find an empty DAC |
| 2948 | */ |
| 2949 | if (from_nid || |
| 2950 | get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || |
| 2951 | alc_is_dac_already_used(codec, conn[i])) |
| 2952 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2953 | } |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2954 | /* aa-mix is requested but not included? */ |
| 2955 | if (!(spec->mixer_nid && with_aa_mix == 1)) |
| 2956 | goto found; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2957 | } |
| 2958 | if (depth >= MAX_NID_PATH_DEPTH) |
| 2959 | return false; |
| 2960 | for (i = 0; i < nums; i++) { |
| 2961 | unsigned int type; |
| 2962 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2963 | if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN || |
| 2964 | type == AC_WID_PIN) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2965 | continue; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2966 | if (__parse_nid_path(codec, from_nid, conn[i], |
| 2967 | with_aa_mix, path, depth + 1)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2968 | goto found; |
| 2969 | } |
| 2970 | return false; |
| 2971 | |
| 2972 | found: |
| 2973 | path->path[path->depth] = conn[i]; |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2974 | path->idx[path->depth + 1] = i; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2975 | 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] | 2976 | path->multi[path->depth + 1] = 1; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2977 | path->depth++; |
| 2978 | return true; |
| 2979 | } |
| 2980 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2981 | /* parse the widget path from the given nid to the target nid; |
| 2982 | * when @from_nid is 0, try to find an empty DAC; |
| 2983 | * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded. |
| 2984 | * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded. |
| 2985 | * 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] | 2986 | */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2987 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2988 | hda_nid_t to_nid, int with_aa_mix, |
| 2989 | struct nid_path *path) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2990 | { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2991 | if (__parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path, 1)) { |
| 2992 | path->path[path->depth] = to_nid; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2993 | path->depth++; |
| 2994 | #if 0 |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2995 | snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n", |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2996 | path->depth, path->path[0], path->path[1], |
| 2997 | path->path[2], path->path[3], path->path[4]); |
| 2998 | #endif |
| 2999 | return true; |
| 3000 | } |
| 3001 | return false; |
| 3002 | } |
| 3003 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3004 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 3005 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3006 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3007 | int i; |
| 3008 | hda_nid_t nid_found = 0; |
| 3009 | |
| 3010 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 3011 | hda_nid_t nid = spec->all_dacs[i]; |
| 3012 | if (!nid || alc_is_dac_already_used(codec, nid)) |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3013 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3014 | if (is_reachable_path(codec, nid, pin)) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3015 | if (nid_found) |
| 3016 | return 0; |
| 3017 | nid_found = nid; |
| 3018 | } |
| 3019 | } |
| 3020 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3021 | } |
| 3022 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3023 | 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] | 3024 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3025 | struct alc_spec *spec = codec->spec; |
| 3026 | int i; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3027 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3028 | for (i = 0; i < spec->paths.used; i++) { |
| 3029 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3030 | if (path->ctls[type] == val) |
| 3031 | return true; |
| 3032 | } |
| 3033 | return false; |
| 3034 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3035 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3036 | /* badness definition */ |
| 3037 | enum { |
| 3038 | /* No primary DAC is found for the main output */ |
| 3039 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3040 | /* No DAC is found for the extra output */ |
| 3041 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3042 | /* No possible multi-ios */ |
| 3043 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3044 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3045 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3046 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3047 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3048 | /* Primary DAC shared with main surrounds */ |
| 3049 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3050 | /* Primary DAC shared with main CLFE */ |
| 3051 | BAD_SHARED_CLFE = 0x10, |
| 3052 | /* Primary DAC shared with extra surrounds */ |
| 3053 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3054 | /* Volume widget is shared */ |
| 3055 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3056 | }; |
| 3057 | |
| 3058 | 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] | 3059 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3060 | 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] | 3061 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3062 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3063 | static bool add_new_out_path(struct hda_codec *codec, hda_nid_t pin, |
| 3064 | hda_nid_t dac) |
| 3065 | { |
| 3066 | struct alc_spec *spec = codec->spec; |
| 3067 | struct nid_path *path; |
| 3068 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3069 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3070 | if (!path) |
| 3071 | return false; |
| 3072 | memset(path, 0, sizeof(*path)); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 3073 | if (parse_nid_path(codec, dac, pin, 0, path)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3074 | return true; |
| 3075 | /* push back */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3076 | spec->paths.used--; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3077 | return false; |
| 3078 | } |
| 3079 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3080 | /* get the path between the given NIDs; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3081 | * passing 0 to either @pin or @dac behaves as a wildcard |
| 3082 | */ |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3083 | static struct nid_path * |
| 3084 | 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] | 3085 | { |
| 3086 | struct alc_spec *spec = codec->spec; |
| 3087 | int i; |
| 3088 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3089 | for (i = 0; i < spec->paths.used; i++) { |
| 3090 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3091 | if (path->depth <= 0) |
| 3092 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3093 | if ((!from_nid || path->path[0] == from_nid) && |
| 3094 | (!to_nid || path->path[path->depth - 1] == to_nid)) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3095 | return path; |
| 3096 | } |
| 3097 | return NULL; |
| 3098 | } |
| 3099 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3100 | /* look for widgets in the path between the given NIDs appropriate for |
| 3101 | * volume and mute controls, and assign the values to ctls[]. |
| 3102 | * |
| 3103 | * When no appropriate widget is found in the path, the badness value |
| 3104 | * is incremented depending on the situation. The function returns the |
| 3105 | * total badness for both volume and mute controls. |
| 3106 | */ |
| 3107 | static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, |
| 3108 | hda_nid_t dac) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3109 | { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3110 | struct nid_path *path = get_nid_path(codec, dac, pin); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3111 | hda_nid_t nid; |
| 3112 | unsigned int val; |
| 3113 | int badness = 0; |
| 3114 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3115 | if (!path) |
| 3116 | return BAD_SHARED_VOL * 2; |
| 3117 | nid = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3118 | if (nid) { |
| 3119 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3120 | if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3121 | badness += BAD_SHARED_VOL; |
| 3122 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3123 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3124 | } else |
| 3125 | badness += BAD_SHARED_VOL; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3126 | nid = alc_look_for_out_mute_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3127 | if (nid) { |
| 3128 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3129 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT || |
| 3130 | nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3131 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3132 | else |
| 3133 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3134 | if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3135 | badness += BAD_SHARED_VOL; |
| 3136 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3137 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3138 | } else |
| 3139 | badness += BAD_SHARED_VOL; |
| 3140 | return badness; |
| 3141 | } |
| 3142 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3143 | struct badness_table { |
| 3144 | int no_primary_dac; /* no primary DAC */ |
| 3145 | int no_dac; /* no secondary DACs */ |
| 3146 | int shared_primary; /* primary DAC is shared with main output */ |
| 3147 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3148 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3149 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3150 | }; |
| 3151 | |
| 3152 | static struct badness_table main_out_badness = { |
| 3153 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3154 | .no_dac = BAD_NO_DAC, |
| 3155 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3156 | .shared_surr = BAD_SHARED_SURROUND, |
| 3157 | .shared_clfe = BAD_SHARED_CLFE, |
| 3158 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3159 | }; |
| 3160 | |
| 3161 | static struct badness_table extra_out_badness = { |
| 3162 | .no_primary_dac = BAD_NO_DAC, |
| 3163 | .no_dac = BAD_NO_DAC, |
| 3164 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3165 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3166 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3167 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3168 | }; |
| 3169 | |
| 3170 | /* try to assign DACs to pins and return the resultant badness */ |
| 3171 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3172 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3173 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3174 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3175 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3176 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3177 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3178 | int badness = 0; |
| 3179 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3180 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3181 | if (!num_outs) |
| 3182 | return 0; |
| 3183 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3184 | for (i = 0; i < num_outs; i++) { |
| 3185 | hda_nid_t pin = pins[i]; |
| 3186 | if (!dacs[i]) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 3187 | dacs[i] = alc_auto_look_for_dac(codec, pin, false); |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3188 | if (!dacs[i] && !i) { |
| 3189 | for (j = 1; j < num_outs; j++) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3190 | if (is_reachable_path(codec, dacs[j], pin)) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3191 | dacs[0] = dacs[j]; |
| 3192 | dacs[j] = 0; |
| 3193 | break; |
| 3194 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3195 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3196 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3197 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3198 | if (!dac) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3199 | if (is_reachable_path(codec, dacs[0], pin)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3200 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3201 | else if (cfg->line_outs > i && |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3202 | is_reachable_path(codec, spec->private_dac_nids[i], pin)) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3203 | dac = spec->private_dac_nids[i]; |
| 3204 | if (dac) { |
| 3205 | if (!i) |
| 3206 | badness += bad->shared_primary; |
| 3207 | else if (i == 1) |
| 3208 | badness += bad->shared_surr; |
| 3209 | else |
| 3210 | badness += bad->shared_clfe; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3211 | } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3212 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3213 | badness += bad->shared_surr_main; |
| 3214 | } else if (!i) |
| 3215 | badness += bad->no_primary_dac; |
| 3216 | else |
| 3217 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3218 | } |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3219 | if (!add_new_out_path(codec, pin, dac)) |
| 3220 | dac = dacs[i] = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3221 | if (dac) |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3222 | badness += assign_out_path_ctls(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3223 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3224 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3225 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3226 | } |
| 3227 | |
| 3228 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3229 | hda_nid_t reference_pin, |
| 3230 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3231 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3232 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3233 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3234 | { |
| 3235 | int i; |
| 3236 | bool found = false; |
| 3237 | for (i = 0; i < outs; i++) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3238 | hda_nid_t dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3239 | if (dacs[i]) |
| 3240 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3241 | dac = get_dac_if_single(codec, pins[i]); |
| 3242 | if (!dac) |
| 3243 | continue; |
| 3244 | if (add_new_out_path(codec, pins[i], dac)) { |
| 3245 | dacs[i] = dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3246 | found = true; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3247 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3248 | } |
| 3249 | return found; |
| 3250 | } |
| 3251 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3252 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3253 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3254 | bool fill_hardwired, |
| 3255 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3256 | { |
| 3257 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3258 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3259 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3260 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3261 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3262 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3263 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3264 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3265 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3266 | 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] | 3267 | spec->multi_ios = 0; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3268 | snd_array_free(&spec->paths); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3269 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3270 | |
| 3271 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3272 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3273 | bool mapped; |
| 3274 | do { |
| 3275 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3276 | cfg->line_out_pins, |
| 3277 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3278 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3279 | cfg->hp_pins, |
| 3280 | spec->multiout.hp_out_nid); |
| 3281 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3282 | cfg->speaker_pins, |
| 3283 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3284 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3285 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3286 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3287 | if (!err) |
| 3288 | mapped = true; |
| 3289 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3290 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3291 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3292 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3293 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3294 | spec->private_dac_nids, |
| 3295 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3296 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3297 | /* re-count num_dacs and squash invalid entries */ |
| 3298 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3299 | for (i = 0; i < cfg->line_outs; i++) { |
| 3300 | if (spec->private_dac_nids[i]) |
| 3301 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3302 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3303 | memmove(spec->private_dac_nids + i, |
| 3304 | spec->private_dac_nids + i + 1, |
| 3305 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3306 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3307 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3308 | } |
| 3309 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3310 | if (fill_mio_first && |
| 3311 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3312 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3313 | 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] | 3314 | if (err < 0) |
| 3315 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3316 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3317 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3318 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3319 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3320 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3321 | spec->multiout.hp_out_nid, |
| 3322 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3323 | if (err < 0) |
| 3324 | return err; |
| 3325 | badness += err; |
| 3326 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3327 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3328 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3329 | cfg->speaker_pins, |
| 3330 | spec->multiout.extra_out_nid, |
| 3331 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3332 | if (err < 0) |
| 3333 | return err; |
| 3334 | badness += err; |
| 3335 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3336 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3337 | 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] | 3338 | if (err < 0) |
| 3339 | return err; |
| 3340 | badness += err; |
| 3341 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3342 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3343 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3344 | int offset = 0; |
| 3345 | if (cfg->line_outs >= 3) |
| 3346 | offset = 1; |
| 3347 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3348 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3349 | if (err < 0) |
| 3350 | return err; |
| 3351 | badness += err; |
| 3352 | } |
| 3353 | |
| 3354 | if (spec->multi_ios == 2) { |
| 3355 | for (i = 0; i < 2; i++) |
| 3356 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3357 | spec->multi_io[i].dac; |
| 3358 | spec->ext_channel_count = 2; |
| 3359 | } else if (spec->multi_ios) { |
| 3360 | spec->multi_ios = 0; |
| 3361 | badness += BAD_MULTI_IO; |
| 3362 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3363 | |
| 3364 | return badness; |
| 3365 | } |
| 3366 | |
| 3367 | #define DEBUG_BADNESS |
| 3368 | |
| 3369 | #ifdef DEBUG_BADNESS |
| 3370 | #define debug_badness snd_printdd |
| 3371 | #else |
| 3372 | #define debug_badness(...) |
| 3373 | #endif |
| 3374 | |
| 3375 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3376 | { |
| 3377 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3378 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3379 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3380 | spec->multiout.dac_nids[0], |
| 3381 | spec->multiout.dac_nids[1], |
| 3382 | spec->multiout.dac_nids[2], |
| 3383 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3384 | if (spec->multi_ios > 0) |
| 3385 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3386 | spec->multi_ios, |
| 3387 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3388 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3389 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3390 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3391 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3392 | spec->multiout.hp_out_nid[0], |
| 3393 | spec->multiout.hp_out_nid[1], |
| 3394 | spec->multiout.hp_out_nid[2], |
| 3395 | spec->multiout.hp_out_nid[3]); |
| 3396 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3397 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3398 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3399 | spec->multiout.extra_out_nid[0], |
| 3400 | spec->multiout.extra_out_nid[1], |
| 3401 | spec->multiout.extra_out_nid[2], |
| 3402 | spec->multiout.extra_out_nid[3]); |
| 3403 | } |
| 3404 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3405 | /* find all available DACs of the codec */ |
| 3406 | static void alc_fill_all_nids(struct hda_codec *codec) |
| 3407 | { |
| 3408 | struct alc_spec *spec = codec->spec; |
| 3409 | int i; |
| 3410 | hda_nid_t nid = codec->start_nid; |
| 3411 | |
| 3412 | spec->num_all_dacs = 0; |
| 3413 | memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); |
| 3414 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 3415 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) |
| 3416 | continue; |
| 3417 | if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { |
| 3418 | snd_printk(KERN_ERR "hda: Too many DACs!\n"); |
| 3419 | break; |
| 3420 | } |
| 3421 | spec->all_dacs[spec->num_all_dacs++] = nid; |
| 3422 | } |
| 3423 | } |
| 3424 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3425 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3426 | { |
| 3427 | struct alc_spec *spec = codec->spec; |
| 3428 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3429 | struct auto_pin_cfg *best_cfg; |
| 3430 | int best_badness = INT_MAX; |
| 3431 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3432 | bool fill_hardwired = true, fill_mio_first = true; |
| 3433 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3434 | bool hp_spk_swapped = false; |
| 3435 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3436 | alc_fill_all_nids(codec); |
| 3437 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3438 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3439 | if (!best_cfg) |
| 3440 | return -ENOMEM; |
| 3441 | *best_cfg = *cfg; |
| 3442 | |
| 3443 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3444 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3445 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3446 | if (badness < 0) { |
| 3447 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3448 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3449 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3450 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3451 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3452 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3453 | debug_show_configs(spec, cfg); |
| 3454 | if (badness < best_badness) { |
| 3455 | best_badness = badness; |
| 3456 | *best_cfg = *cfg; |
| 3457 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3458 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3459 | } |
| 3460 | if (!badness) |
| 3461 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3462 | fill_mio_first = !fill_mio_first; |
| 3463 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3464 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3465 | fill_hardwired = !fill_hardwired; |
| 3466 | if (!fill_hardwired) |
| 3467 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3468 | if (hp_spk_swapped) |
| 3469 | break; |
| 3470 | hp_spk_swapped = true; |
| 3471 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3472 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3473 | cfg->hp_outs = cfg->line_outs; |
| 3474 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3475 | sizeof(cfg->hp_pins)); |
| 3476 | cfg->line_outs = cfg->speaker_outs; |
| 3477 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3478 | sizeof(cfg->speaker_pins)); |
| 3479 | cfg->speaker_outs = 0; |
| 3480 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3481 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3482 | fill_hardwired = true; |
| 3483 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3484 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3485 | if (cfg->hp_outs > 0 && |
| 3486 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3487 | cfg->speaker_outs = cfg->line_outs; |
| 3488 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3489 | sizeof(cfg->speaker_pins)); |
| 3490 | cfg->line_outs = cfg->hp_outs; |
| 3491 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3492 | sizeof(cfg->hp_pins)); |
| 3493 | cfg->hp_outs = 0; |
| 3494 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3495 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3496 | fill_hardwired = true; |
| 3497 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3498 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3499 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3500 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3501 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3502 | if (badness) { |
| 3503 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3504 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3505 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3506 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3507 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3508 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3509 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3510 | if (cfg->line_out_pins[0]) { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3511 | struct nid_path *path = get_nid_path(codec, |
| 3512 | spec->multiout.dac_nids[0], |
| 3513 | cfg->line_out_pins[0]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3514 | if (path) |
| 3515 | spec->vmaster_nid = alc_look_for_out_vol_nid(codec, path); |
| 3516 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3517 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3518 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3519 | return 0; |
| 3520 | } |
| 3521 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3522 | /* replace the channels in the composed amp value with the given number */ |
| 3523 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) |
| 3524 | { |
| 3525 | val &= ~(0x3U << 16); |
| 3526 | val |= chs << 16; |
| 3527 | return val; |
| 3528 | } |
| 3529 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3530 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3531 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3532 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3533 | struct nid_path *path) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3534 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3535 | unsigned int val; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3536 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3537 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3538 | val = path->ctls[NID_PATH_VOL_CTL]; |
| 3539 | if (!val) |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3540 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3541 | val = amp_val_replace_channels(val, chs); |
| 3542 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, val); |
| 3543 | } |
| 3544 | |
| 3545 | /* return the channel bits suitable for the given path->ctls[] */ |
| 3546 | static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, |
| 3547 | int type) |
| 3548 | { |
| 3549 | int chs = 1; /* mono (left only) */ |
| 3550 | if (path) { |
| 3551 | hda_nid_t nid = get_amp_nid_(path->ctls[type]); |
| 3552 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) |
| 3553 | chs = 3; /* stereo */ |
| 3554 | } |
| 3555 | return chs; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3556 | } |
| 3557 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3558 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3559 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3560 | struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3561 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3562 | int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); |
| 3563 | return alc_auto_add_vol_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3564 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3565 | |
| 3566 | /* create a mute-switch for the given mixer widget; |
| 3567 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3568 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3569 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3570 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3571 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3572 | struct nid_path *path) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3573 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3574 | unsigned int val; |
| 3575 | int type = ALC_CTL_WIDGET_MUTE; |
| 3576 | |
| 3577 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3578 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3579 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 3580 | if (!val) |
| 3581 | return 0; |
| 3582 | val = amp_val_replace_channels(val, chs); |
| 3583 | if (get_amp_direction_(val) == HDA_INPUT) { |
| 3584 | hda_nid_t nid = get_amp_nid_(val); |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3585 | int nums = snd_hda_get_num_conns(codec, nid); |
| 3586 | if (nums > 1) { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3587 | type = ALC_CTL_BIND_MUTE; |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3588 | val |= nums << 19; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3589 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3590 | } |
| 3591 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3592 | } |
| 3593 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3594 | 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] | 3595 | int cidx, struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3596 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3597 | int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); |
| 3598 | return alc_auto_add_sw_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3599 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3600 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3601 | 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] | 3602 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3603 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3604 | int i; |
| 3605 | |
| 3606 | for (i = path->depth - 1; i >= 0; i--) { |
| 3607 | if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) |
| 3608 | return path->path[i]; |
| 3609 | if (i != path->depth - 1 && i != 0 && |
| 3610 | nid_has_mute(codec, path->path[i], HDA_INPUT)) |
| 3611 | return path->path[i]; |
| 3612 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3613 | return 0; |
| 3614 | } |
| 3615 | |
| 3616 | 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] | 3617 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3618 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3619 | int i; |
| 3620 | |
| 3621 | for (i = path->depth - 1; i >= 0; i--) { |
| 3622 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) |
| 3623 | return path->path[i]; |
| 3624 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3625 | return 0; |
| 3626 | } |
| 3627 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3628 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3629 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3630 | const struct auto_pin_cfg *cfg) |
| 3631 | { |
| 3632 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3633 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3634 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3635 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3636 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3637 | noutputs += spec->multi_ios; |
| 3638 | |
| 3639 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3640 | const char *name; |
| 3641 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3642 | hda_nid_t dac, pin; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3643 | struct nid_path *path; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3644 | |
| 3645 | dac = spec->multiout.dac_nids[i]; |
| 3646 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3647 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3648 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3649 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3650 | index = 0; |
| 3651 | name = channel_name[i]; |
| 3652 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3653 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3654 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3655 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3656 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3657 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3658 | if (!path) |
| 3659 | continue; |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3660 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3661 | /* Center/LFE */ |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3662 | err = alc_auto_add_vol_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3663 | if (err < 0) |
| 3664 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3665 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3666 | if (err < 0) |
| 3667 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3668 | err = alc_auto_add_sw_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3669 | if (err < 0) |
| 3670 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3671 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3672 | if (err < 0) |
| 3673 | return err; |
| 3674 | } else { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3675 | err = alc_auto_add_stereo_vol(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3676 | if (err < 0) |
| 3677 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3678 | err = alc_auto_add_stereo_sw(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3679 | if (err < 0) |
| 3680 | return err; |
| 3681 | } |
| 3682 | } |
| 3683 | return 0; |
| 3684 | } |
| 3685 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3686 | 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] | 3687 | hda_nid_t dac, const char *pfx, |
| 3688 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3689 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3690 | struct nid_path *path; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3691 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3692 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3693 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3694 | if (!path) |
| 3695 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3696 | /* bind volume control will be created in the case of dac = 0 */ |
| 3697 | if (dac) { |
| 3698 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, path); |
| 3699 | if (err < 0) |
| 3700 | return err; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3701 | } |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3702 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, path); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3703 | if (err < 0) |
| 3704 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3705 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3706 | } |
| 3707 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3708 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3709 | unsigned int nums, |
| 3710 | struct hda_ctl_ops *ops) |
| 3711 | { |
| 3712 | struct alc_spec *spec = codec->spec; |
| 3713 | struct hda_bind_ctls **ctlp, *ctl; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3714 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3715 | if (!ctlp) |
| 3716 | return NULL; |
| 3717 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3718 | *ctlp = ctl; |
| 3719 | if (ctl) |
| 3720 | ctl->ops = ops; |
| 3721 | return ctl; |
| 3722 | } |
| 3723 | |
| 3724 | /* add playback controls for speaker and HP outputs */ |
| 3725 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3726 | const hda_nid_t *pins, |
| 3727 | const hda_nid_t *dacs, |
| 3728 | const char *pfx) |
| 3729 | { |
| 3730 | struct alc_spec *spec = codec->spec; |
| 3731 | struct hda_bind_ctls *ctl; |
| 3732 | char name[32]; |
| 3733 | int i, n, err; |
| 3734 | |
| 3735 | if (!num_pins || !pins[0]) |
| 3736 | return 0; |
| 3737 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3738 | if (num_pins == 1) { |
| 3739 | hda_nid_t dac = *dacs; |
| 3740 | if (!dac) |
| 3741 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3742 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3743 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3744 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3745 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3746 | hda_nid_t dac; |
| 3747 | if (dacs[num_pins - 1]) |
| 3748 | dac = dacs[i]; /* with individual volumes */ |
| 3749 | else |
| 3750 | dac = 0; |
| 3751 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3752 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3753 | "Bass Speaker", 0); |
| 3754 | } else if (num_pins >= 3) { |
| 3755 | snprintf(name, sizeof(name), "%s %s", |
| 3756 | pfx, channel_name[i]); |
| 3757 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3758 | name, 0); |
| 3759 | } else { |
| 3760 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3761 | pfx, i); |
| 3762 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3763 | if (err < 0) |
| 3764 | return err; |
| 3765 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3766 | if (dacs[num_pins - 1]) |
| 3767 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3768 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3769 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3770 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3771 | if (!ctl) |
| 3772 | return -ENOMEM; |
| 3773 | n = 0; |
| 3774 | for (i = 0; i < num_pins; i++) { |
| 3775 | hda_nid_t vol; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3776 | struct nid_path *path; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3777 | if (!pins[i] || !dacs[i]) |
| 3778 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3779 | path = get_nid_path(codec, dacs[i], pins[i]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3780 | if (!path) |
| 3781 | continue; |
| 3782 | vol = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3783 | if (vol) |
| 3784 | ctl->values[n++] = |
| 3785 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3786 | } |
| 3787 | if (n) { |
| 3788 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3789 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3790 | if (err < 0) |
| 3791 | return err; |
| 3792 | } |
| 3793 | return 0; |
| 3794 | } |
| 3795 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3796 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3797 | { |
| 3798 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3799 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3800 | spec->autocfg.hp_pins, |
| 3801 | spec->multiout.hp_out_nid, |
| 3802 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3806 | { |
| 3807 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3808 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3809 | spec->autocfg.speaker_pins, |
| 3810 | spec->multiout.extra_out_nid, |
| 3811 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3812 | } |
| 3813 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3814 | /* check whether a control with the given (nid, dir, idx) was assigned */ |
| 3815 | static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, |
| 3816 | int dir, int idx) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3817 | { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3818 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3819 | int i, type; |
| 3820 | |
| 3821 | for (i = 0; i < spec->paths.used; i++) { |
| 3822 | struct nid_path *p = snd_array_elem(&spec->paths, i); |
| 3823 | if (p->depth <= 0) |
| 3824 | continue; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 3825 | for (type = 0; type < NID_PATH_NUM_CTLS; type++) { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3826 | unsigned int val = p->ctls[type]; |
| 3827 | if (get_amp_nid_(val) == nid && |
| 3828 | get_amp_direction_(val) == dir && |
| 3829 | get_amp_index_(val) == idx) |
| 3830 | return true; |
| 3831 | } |
| 3832 | } |
| 3833 | return false; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3834 | } |
| 3835 | |
| 3836 | /* can have the amp-in capability? */ |
| 3837 | static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3838 | { |
| 3839 | hda_nid_t nid = path->path[idx]; |
| 3840 | unsigned int caps = get_wcaps(codec, nid); |
| 3841 | unsigned int type = get_wcaps_type(caps); |
| 3842 | |
| 3843 | if (!(caps & AC_WCAP_IN_AMP)) |
| 3844 | return false; |
| 3845 | if (type == AC_WID_PIN && idx > 0) /* only for input pins */ |
| 3846 | return false; |
| 3847 | return true; |
| 3848 | } |
| 3849 | |
| 3850 | /* can have the amp-out capability? */ |
| 3851 | static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3852 | { |
| 3853 | hda_nid_t nid = path->path[idx]; |
| 3854 | unsigned int caps = get_wcaps(codec, nid); |
| 3855 | unsigned int type = get_wcaps_type(caps); |
| 3856 | |
| 3857 | if (!(caps & AC_WCAP_OUT_AMP)) |
| 3858 | return false; |
| 3859 | if (type == AC_WID_PIN && !idx) /* only for output pins */ |
| 3860 | return false; |
| 3861 | return true; |
| 3862 | } |
| 3863 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3864 | /* check whether the given (nid,dir,idx) is active */ |
| 3865 | static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, |
| 3866 | unsigned int idx, unsigned int dir) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3867 | { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3868 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3869 | int i, n; |
| 3870 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3871 | for (n = 0; n < spec->paths.used; n++) { |
| 3872 | struct nid_path *path = snd_array_elem(&spec->paths, n); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3873 | if (!path->active) |
| 3874 | continue; |
| 3875 | for (i = 0; i < path->depth; i++) { |
| 3876 | if (path->path[i] == nid) { |
| 3877 | if (dir == HDA_OUTPUT || path->idx[i] == idx) |
| 3878 | return true; |
| 3879 | break; |
| 3880 | } |
| 3881 | } |
| 3882 | } |
| 3883 | return false; |
| 3884 | } |
| 3885 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3886 | /* get the default amp value for the target state */ |
| 3887 | static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, |
| 3888 | int dir, bool enable) |
| 3889 | { |
| 3890 | unsigned int caps; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3891 | unsigned int val = 0; |
| 3892 | |
| 3893 | caps = query_amp_caps(codec, nid, dir); |
| 3894 | if (caps & AC_AMPCAP_NUM_STEPS) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3895 | /* set to 0dB */ |
| 3896 | if (enable) |
| 3897 | val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3898 | } |
| 3899 | if (caps & AC_AMPCAP_MUTE) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3900 | if (!enable) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3901 | val |= HDA_AMP_MUTE; |
| 3902 | } |
| 3903 | return val; |
| 3904 | } |
| 3905 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3906 | /* initialize the amp value (only at the first time) */ |
| 3907 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
| 3908 | { |
| 3909 | int val = get_amp_val_to_activate(codec, nid, dir, false); |
| 3910 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); |
| 3911 | } |
| 3912 | |
| 3913 | static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 3914 | int idx, bool enable) |
| 3915 | { |
| 3916 | int val; |
| 3917 | if (is_ctl_associated(codec, nid, dir, idx) || |
| 3918 | is_active_nid(codec, nid, dir, idx)) |
| 3919 | return; |
| 3920 | val = get_amp_val_to_activate(codec, nid, dir, enable); |
| 3921 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, 0xff, val); |
| 3922 | } |
| 3923 | |
| 3924 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
| 3925 | int i, bool enable) |
| 3926 | { |
| 3927 | hda_nid_t nid = path->path[i]; |
| 3928 | init_amp(codec, nid, HDA_OUTPUT, 0); |
| 3929 | activate_amp(codec, nid, HDA_OUTPUT, 0, enable); |
| 3930 | } |
| 3931 | |
| 3932 | static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, |
| 3933 | int i, bool enable) |
| 3934 | { |
| 3935 | struct alc_spec *spec = codec->spec; |
| 3936 | hda_nid_t conn[16]; |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3937 | int n, nums, idx; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3938 | hda_nid_t nid = path->path[i]; |
| 3939 | |
| 3940 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3941 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN) { |
| 3942 | nums = 1; |
| 3943 | idx = 0; |
| 3944 | } else |
| 3945 | idx = path->idx[i]; |
| 3946 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3947 | for (n = 0; n < nums; n++) |
| 3948 | init_amp(codec, nid, HDA_INPUT, n); |
| 3949 | |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3950 | if (is_ctl_associated(codec, nid, HDA_INPUT, idx)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3951 | return; |
| 3952 | |
| 3953 | /* here is a little bit tricky in comparison with activate_amp_out(); |
| 3954 | * when aa-mixer is available, we need to enable the path as well |
| 3955 | */ |
| 3956 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3957 | if (n != idx && conn[n] != spec->mixer_nid) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3958 | continue; |
| 3959 | activate_amp(codec, nid, HDA_INPUT, n, enable); |
| 3960 | } |
| 3961 | } |
| 3962 | |
| 3963 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 3964 | bool enable) |
| 3965 | { |
| 3966 | int i; |
| 3967 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3968 | if (!enable) |
| 3969 | path->active = false; |
| 3970 | |
| 3971 | for (i = path->depth - 1; i >= 0; i--) { |
| 3972 | if (path->multi[i]) |
| 3973 | snd_hda_codec_write_cache(codec, path->path[i], 0, |
| 3974 | AC_VERB_SET_CONNECT_SEL, |
| 3975 | path->idx[i]); |
| 3976 | if (has_amp_in(codec, path, i)) |
| 3977 | activate_amp_in(codec, path, i, enable); |
| 3978 | if (has_amp_out(codec, path, i)) |
| 3979 | activate_amp_out(codec, path, i, enable); |
| 3980 | } |
| 3981 | |
| 3982 | if (enable) |
| 3983 | path->active = true; |
| 3984 | } |
| 3985 | |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3986 | /* configure the path from the given dac to the pin as the proper output */ |
| 3987 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3988 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3989 | hda_nid_t dac) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3990 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3991 | struct nid_path *path; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3992 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3993 | snd_hda_set_pin_ctl_cache(codec, pin, pin_type); |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3994 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3995 | if (!path) |
| 3996 | return; |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 3997 | if (path->active) |
| 3998 | return; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3999 | activate_path(codec, path, true); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4000 | } |
| 4001 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4002 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4003 | { |
| 4004 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 4005 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4006 | int i; |
| 4007 | |
| 4008 | for (i = 0; i <= HDA_SIDE; i++) { |
| 4009 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4010 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4011 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4012 | spec->multiout.dac_nids[i]); |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 4013 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4014 | } |
| 4015 | } |
| 4016 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4017 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4018 | { |
| 4019 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4020 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4021 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4022 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 4023 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4024 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 4025 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 4026 | pin = spec->autocfg.hp_pins[i]; |
| 4027 | if (!pin) |
| 4028 | break; |
| 4029 | dac = spec->multiout.hp_out_nid[i]; |
| 4030 | if (!dac) { |
| 4031 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 4032 | dac = spec->multiout.hp_out_nid[0]; |
| 4033 | else |
| 4034 | dac = spec->multiout.dac_nids[0]; |
| 4035 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4036 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4037 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4038 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4039 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4040 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4041 | pin = spec->autocfg.speaker_pins[i]; |
| 4042 | if (!pin) |
| 4043 | break; |
| 4044 | dac = spec->multiout.extra_out_nid[i]; |
| 4045 | if (!dac) { |
| 4046 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 4047 | dac = spec->multiout.extra_out_nid[0]; |
| 4048 | else |
| 4049 | dac = spec->multiout.dac_nids[0]; |
| 4050 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4051 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4052 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4053 | } |
| 4054 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4055 | /* check whether the given pin can be a multi-io pin */ |
| 4056 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 4057 | unsigned int location, hda_nid_t nid) |
| 4058 | { |
| 4059 | unsigned int defcfg, caps; |
| 4060 | |
| 4061 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 4062 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 4063 | return false; |
| 4064 | if (location && get_defcfg_location(defcfg) != location) |
| 4065 | return false; |
| 4066 | caps = snd_hda_query_pin_caps(codec, nid); |
| 4067 | if (!(caps & AC_PINCAP_OUT)) |
| 4068 | return false; |
| 4069 | return true; |
| 4070 | } |
| 4071 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4072 | /* |
| 4073 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4074 | * |
| 4075 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 4076 | * zero if any pins are filled, non-zero if nothing found. |
| 4077 | * When hardwired is off, try to fill possible input pins, and returns |
| 4078 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4079 | */ |
| 4080 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4081 | hda_nid_t reference_pin, |
| 4082 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4083 | { |
| 4084 | struct alc_spec *spec = codec->spec; |
| 4085 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4086 | int type, i, j, dacs, num_pins, old_pins; |
| 4087 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 4088 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4089 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4090 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4091 | old_pins = spec->multi_ios; |
| 4092 | if (old_pins >= 2) |
| 4093 | goto end_fill; |
| 4094 | |
| 4095 | num_pins = 0; |
| 4096 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4097 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4098 | if (cfg->inputs[i].type != type) |
| 4099 | continue; |
| 4100 | if (can_be_multiio_pin(codec, location, |
| 4101 | cfg->inputs[i].pin)) |
| 4102 | num_pins++; |
| 4103 | } |
| 4104 | } |
| 4105 | if (num_pins < 2) |
| 4106 | goto end_fill; |
| 4107 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4108 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4109 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4110 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4111 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4112 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4113 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4114 | if (cfg->inputs[i].type != type) |
| 4115 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4116 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4117 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4118 | for (j = 0; j < spec->multi_ios; j++) { |
| 4119 | if (nid == spec->multi_io[j].pin) |
| 4120 | break; |
| 4121 | } |
| 4122 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4123 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4124 | |
| 4125 | if (offset && offset + spec->multi_ios < dacs) { |
| 4126 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 4127 | if (!is_reachable_path(codec, dac, nid)) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4128 | dac = 0; |
| 4129 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4130 | if (hardwired) |
| 4131 | dac = get_dac_if_single(codec, nid); |
| 4132 | else if (!dac) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 4133 | dac = alc_auto_look_for_dac(codec, nid, false); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4134 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4135 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4136 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4137 | } |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4138 | if (!add_new_out_path(codec, nid, dac)) { |
| 4139 | badness++; |
| 4140 | continue; |
| 4141 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4142 | spec->multi_io[spec->multi_ios].pin = nid; |
| 4143 | spec->multi_io[spec->multi_ios].dac = dac; |
| 4144 | spec->multi_ios++; |
| 4145 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4146 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4147 | } |
| 4148 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4149 | end_fill: |
| 4150 | if (badness) |
| 4151 | badness = BAD_MULTI_IO; |
| 4152 | if (old_pins == spec->multi_ios) { |
| 4153 | if (hardwired) |
| 4154 | return 1; /* nothing found */ |
| 4155 | else |
| 4156 | return badness; /* no badness if nothing found */ |
| 4157 | } |
| 4158 | if (!hardwired && spec->multi_ios < 2) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4159 | /* cancel newly assigned paths */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4160 | spec->paths.used -= spec->multi_ios - old_pins; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4161 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4162 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4163 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4164 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 4165 | /* assign volume and mute controls */ |
| 4166 | for (i = old_pins; i < spec->multi_ios; i++) |
| 4167 | badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, |
| 4168 | spec->multi_io[i].dac); |
| 4169 | |
| 4170 | return badness; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4171 | } |
| 4172 | |
| 4173 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 4174 | struct snd_ctl_elem_info *uinfo) |
| 4175 | { |
| 4176 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4177 | struct alc_spec *spec = codec->spec; |
| 4178 | |
| 4179 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 4180 | uinfo->count = 1; |
| 4181 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 4182 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 4183 | uinfo->value.enumerated.item = spec->multi_ios; |
| 4184 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 4185 | (uinfo->value.enumerated.item + 1) * 2); |
| 4186 | return 0; |
| 4187 | } |
| 4188 | |
| 4189 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 4190 | struct snd_ctl_elem_value *ucontrol) |
| 4191 | { |
| 4192 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4193 | struct alc_spec *spec = codec->spec; |
| 4194 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 4195 | return 0; |
| 4196 | } |
| 4197 | |
| 4198 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 4199 | { |
| 4200 | struct alc_spec *spec = codec->spec; |
| 4201 | hda_nid_t nid = spec->multi_io[idx].pin; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4202 | struct nid_path *path; |
| 4203 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 4204 | path = get_nid_path(codec, spec->multi_io[idx].dac, nid); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4205 | if (!path) |
| 4206 | return -EINVAL; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4207 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4208 | if (path->active == output) |
| 4209 | return 0; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4210 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4211 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4212 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4213 | activate_path(codec, path, true); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4214 | } else { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4215 | activate_path(codec, path, false); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4216 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4217 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4218 | } |
| 4219 | return 0; |
| 4220 | } |
| 4221 | |
| 4222 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4223 | struct snd_ctl_elem_value *ucontrol) |
| 4224 | { |
| 4225 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4226 | struct alc_spec *spec = codec->spec; |
| 4227 | int i, ch; |
| 4228 | |
| 4229 | ch = ucontrol->value.enumerated.item[0]; |
| 4230 | if (ch < 0 || ch > spec->multi_ios) |
| 4231 | return -EINVAL; |
| 4232 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4233 | return 0; |
| 4234 | spec->ext_channel_count = (ch + 1) * 2; |
| 4235 | for (i = 0; i < spec->multi_ios; i++) |
| 4236 | alc_set_multi_io(codec, i, i < ch); |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4237 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4238 | spec->const_channel_count); |
| 4239 | if (spec->need_dac_fix) |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4240 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4241 | return 1; |
| 4242 | } |
| 4243 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4244 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4245 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4246 | .name = "Channel Mode", |
| 4247 | .info = alc_auto_ch_mode_info, |
| 4248 | .get = alc_auto_ch_mode_get, |
| 4249 | .put = alc_auto_ch_mode_put, |
| 4250 | }; |
| 4251 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4252 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4253 | { |
| 4254 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4255 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4256 | if (spec->multi_ios > 0) { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 4257 | if (!alc_kcontrol_new(spec, "Channel Mode", |
| 4258 | &alc_auto_channel_mode_enum)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4259 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4260 | } |
| 4261 | return 0; |
| 4262 | } |
| 4263 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4264 | static void alc_auto_init_multi_io(struct hda_codec *codec) |
| 4265 | { |
| 4266 | struct alc_spec *spec = codec->spec; |
| 4267 | int i; |
| 4268 | |
| 4269 | for (i = 0; i < spec->multi_ios; i++) { |
| 4270 | hda_nid_t pin = spec->multi_io[i].pin; |
| 4271 | struct nid_path *path; |
| 4272 | path = get_nid_path(codec, spec->multi_io[i].dac, pin); |
| 4273 | if (!path) |
| 4274 | continue; |
| 4275 | if (!spec->multi_io[i].ctl_in) |
| 4276 | spec->multi_io[i].ctl_in = |
| 4277 | snd_hda_codec_update_cache(codec, pin, 0, |
| 4278 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4279 | activate_path(codec, path, path->active); |
| 4280 | } |
| 4281 | } |
| 4282 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4283 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 4284 | * active input pins |
| 4285 | */ |
| 4286 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 4287 | { |
| 4288 | struct alc_spec *spec = codec->spec; |
| 4289 | const struct hda_input_mux *imux; |
| 4290 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4291 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4292 | int i, n, nums; |
| 4293 | |
| 4294 | imux = spec->input_mux; |
| 4295 | if (!imux) |
| 4296 | return; |
| 4297 | if (spec->dyn_adc_switch) |
| 4298 | return; |
| 4299 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4300 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4301 | nums = 0; |
| 4302 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 4303 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 4304 | int num_conns = snd_hda_get_num_conns(codec, cap); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4305 | for (i = 0; i < imux->num_items; i++) { |
| 4306 | hda_nid_t pin = spec->imux_pins[i]; |
| 4307 | if (pin) { |
| 4308 | if (get_connection_index(codec, cap, pin) < 0) |
| 4309 | break; |
| 4310 | } else if (num_conns <= imux->items[i].index) |
| 4311 | break; |
| 4312 | } |
| 4313 | if (i >= imux->num_items) { |
| 4314 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 4315 | capsrc_nids[nums++] = cap; |
| 4316 | } |
| 4317 | } |
| 4318 | if (!nums) { |
| 4319 | /* check whether ADC-switch is possible */ |
| 4320 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4321 | if (spec->shared_mic_hp) { |
| 4322 | spec->shared_mic_hp = 0; |
| 4323 | spec->private_imux[0].num_items = 1; |
| 4324 | goto again; |
| 4325 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4326 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 4327 | " using fallback 0x%x\n", |
| 4328 | codec->chip_name, spec->private_adc_nids[0]); |
| 4329 | spec->num_adc_nids = 1; |
| 4330 | spec->auto_mic = 0; |
| 4331 | return; |
| 4332 | } |
| 4333 | } else if (nums != spec->num_adc_nids) { |
| 4334 | memcpy(spec->private_adc_nids, adc_nids, |
| 4335 | nums * sizeof(hda_nid_t)); |
| 4336 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 4337 | nums * sizeof(hda_nid_t)); |
| 4338 | spec->num_adc_nids = nums; |
| 4339 | } |
| 4340 | |
| 4341 | if (spec->auto_mic) |
| 4342 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4343 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4344 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 4345 | } |
| 4346 | |
| 4347 | /* |
| 4348 | * initialize ADC paths |
| 4349 | */ |
| 4350 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 4351 | { |
| 4352 | struct alc_spec *spec = codec->spec; |
| 4353 | hda_nid_t nid; |
| 4354 | |
| 4355 | nid = spec->adc_nids[adc_idx]; |
| 4356 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4357 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4358 | snd_hda_codec_write(codec, nid, 0, |
| 4359 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4360 | AMP_IN_MUTE(0)); |
| 4361 | return; |
| 4362 | } |
| 4363 | if (!spec->capsrc_nids) |
| 4364 | return; |
| 4365 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4366 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4367 | snd_hda_codec_write(codec, nid, 0, |
| 4368 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4369 | AMP_OUT_MUTE); |
| 4370 | } |
| 4371 | |
| 4372 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4373 | { |
| 4374 | struct alc_spec *spec = codec->spec; |
| 4375 | int c, nums; |
| 4376 | |
| 4377 | for (c = 0; c < spec->num_adc_nids; c++) |
| 4378 | alc_auto_init_adc(codec, c); |
| 4379 | if (spec->dyn_adc_switch) |
| 4380 | nums = 1; |
| 4381 | else |
| 4382 | nums = spec->num_adc_nids; |
| 4383 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 4384 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4385 | } |
| 4386 | |
| 4387 | /* add mic boosts if needed */ |
| 4388 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4389 | { |
| 4390 | struct alc_spec *spec = codec->spec; |
| 4391 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4392 | int i, err; |
| 4393 | int type_idx = 0; |
| 4394 | hda_nid_t nid; |
| 4395 | const char *prev_label = NULL; |
| 4396 | |
| 4397 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4398 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4399 | break; |
| 4400 | nid = cfg->inputs[i].pin; |
| 4401 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4402 | const char *label; |
| 4403 | char boost_label[32]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4404 | struct nid_path *path; |
| 4405 | unsigned int val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4406 | |
| 4407 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4408 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4409 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4410 | if (prev_label && !strcmp(label, prev_label)) |
| 4411 | type_idx++; |
| 4412 | else |
| 4413 | type_idx = 0; |
| 4414 | prev_label = label; |
| 4415 | |
| 4416 | snprintf(boost_label, sizeof(boost_label), |
| 4417 | "%s Boost Volume", label); |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4418 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4419 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4420 | boost_label, type_idx, val); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4421 | if (err < 0) |
| 4422 | return err; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4423 | |
| 4424 | path = get_nid_path(codec, nid, 0); |
| 4425 | if (path) |
| 4426 | path->ctls[NID_PATH_BOOST_CTL] = val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4427 | } |
| 4428 | } |
| 4429 | return 0; |
| 4430 | } |
| 4431 | |
| 4432 | /* select or unmute the given capsrc route */ |
| 4433 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4434 | int idx) |
| 4435 | { |
| 4436 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4437 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4438 | HDA_AMP_MUTE, 0); |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 4439 | } else if (snd_hda_get_num_conns(codec, cap) > 1) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4440 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4441 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4442 | } |
| 4443 | } |
| 4444 | |
| 4445 | /* set the default connection to that pin */ |
| 4446 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4447 | { |
| 4448 | struct alc_spec *spec = codec->spec; |
| 4449 | int i; |
| 4450 | |
| 4451 | if (!pin) |
| 4452 | return 0; |
| 4453 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4454 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4455 | int idx; |
| 4456 | |
| 4457 | idx = get_connection_index(codec, cap, pin); |
| 4458 | if (idx < 0) |
| 4459 | continue; |
| 4460 | select_or_unmute_capsrc(codec, cap, idx); |
| 4461 | return i; /* return the found index */ |
| 4462 | } |
| 4463 | return -1; /* not found */ |
| 4464 | } |
| 4465 | |
| 4466 | /* initialize some special cases for input sources */ |
| 4467 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4468 | { |
| 4469 | struct alc_spec *spec = codec->spec; |
| 4470 | int i; |
| 4471 | |
| 4472 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4473 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4474 | } |
| 4475 | |
| 4476 | /* assign appropriate capture mixers */ |
| 4477 | static void set_capture_mixer(struct hda_codec *codec) |
| 4478 | { |
| 4479 | struct alc_spec *spec = codec->spec; |
| 4480 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4481 | { alc_capture_mixer_nosrc1, |
| 4482 | alc_capture_mixer_nosrc2, |
| 4483 | alc_capture_mixer_nosrc3 }, |
| 4484 | { alc_capture_mixer1, |
| 4485 | alc_capture_mixer2, |
| 4486 | alc_capture_mixer3 }, |
| 4487 | }; |
| 4488 | |
| 4489 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4490 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4491 | if (!spec->capsrc_nids) |
| 4492 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4493 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4494 | return; /* no volume in capsrc, too */ |
| 4495 | spec->vol_in_capsrc = 1; |
| 4496 | } |
| 4497 | |
| 4498 | if (spec->num_adc_nids > 0) { |
| 4499 | int mux = 0; |
| 4500 | int num_adcs = 0; |
| 4501 | |
| 4502 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4503 | mux = 1; |
| 4504 | if (spec->auto_mic) { |
| 4505 | num_adcs = 1; |
| 4506 | mux = 0; |
| 4507 | } else if (spec->dyn_adc_switch) |
| 4508 | num_adcs = 1; |
| 4509 | if (!num_adcs) { |
| 4510 | if (spec->num_adc_nids > 3) |
| 4511 | spec->num_adc_nids = 3; |
| 4512 | else if (!spec->num_adc_nids) |
| 4513 | return; |
| 4514 | num_adcs = spec->num_adc_nids; |
| 4515 | } |
| 4516 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4517 | } |
| 4518 | } |
| 4519 | |
| 4520 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4521 | * standard auto-parser initializations |
| 4522 | */ |
| 4523 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4524 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4525 | alc_auto_init_multi_out(codec); |
| 4526 | alc_auto_init_extra_out(codec); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4527 | alc_auto_init_multi_io(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4528 | alc_auto_init_analog_input(codec); |
| 4529 | alc_auto_init_input_src(codec); |
| 4530 | alc_auto_init_digital(codec); |
David Henningsson | a7a0a64 | 2012-07-05 12:00:12 +0200 | [diff] [blame] | 4531 | alc_inithook(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4532 | } |
| 4533 | |
| 4534 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4535 | * Digital-beep handlers |
| 4536 | */ |
| 4537 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4538 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4539 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4540 | |
| 4541 | static const struct snd_pci_quirk beep_white_list[] = { |
Duncan Roe | 7110005 | 2012-10-10 14:19:50 +0200 | [diff] [blame] | 4542 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4543 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4544 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4545 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4546 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4547 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4548 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4549 | {} |
| 4550 | }; |
| 4551 | |
| 4552 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4553 | { |
| 4554 | struct alc_spec *spec = codec->spec; |
| 4555 | const struct snd_pci_quirk *q; |
| 4556 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4557 | if (q) |
| 4558 | return q->value; |
| 4559 | return spec->cdefine.enable_pcbeep; |
| 4560 | } |
| 4561 | #else |
| 4562 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4563 | #define has_cdefine_beep(codec) 0 |
| 4564 | #endif |
| 4565 | |
| 4566 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4567 | /* return 1 if successful, 0 if the proper config is not found, |
| 4568 | * or a negative error code |
| 4569 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4570 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4571 | const hda_nid_t *ignore_nids, |
| 4572 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4573 | { |
| 4574 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4575 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4576 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4577 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4578 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4579 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4580 | if (err < 0) |
| 4581 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4582 | if (!cfg->line_outs) { |
| 4583 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4584 | spec->multiout.max_channels = 2; |
| 4585 | spec->no_analog = 1; |
| 4586 | goto dig_only; |
| 4587 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4588 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4589 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4590 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4591 | if (!spec->no_primary_hp && |
| 4592 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4593 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4594 | /* use HP as primary out */ |
| 4595 | cfg->speaker_outs = cfg->line_outs; |
| 4596 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4597 | sizeof(cfg->speaker_pins)); |
| 4598 | cfg->line_outs = cfg->hp_outs; |
| 4599 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4600 | cfg->hp_outs = 0; |
| 4601 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4602 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4603 | } |
| 4604 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4605 | err = alc_auto_fill_dac_nids(codec); |
| 4606 | if (err < 0) |
| 4607 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4608 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4609 | if (err < 0) |
| 4610 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4611 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4612 | if (err < 0) |
| 4613 | return err; |
| 4614 | err = alc_auto_create_hp_out(codec); |
| 4615 | if (err < 0) |
| 4616 | return err; |
| 4617 | err = alc_auto_create_speaker_out(codec); |
| 4618 | if (err < 0) |
| 4619 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4620 | err = alc_auto_create_shared_input(codec); |
| 4621 | if (err < 0) |
| 4622 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4623 | err = alc_auto_create_input_ctls(codec); |
| 4624 | if (err < 0) |
| 4625 | return err; |
| 4626 | |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4627 | /* check the multiple speaker pins */ |
| 4628 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4629 | spec->const_channel_count = cfg->line_outs * 2; |
| 4630 | else |
| 4631 | spec->const_channel_count = cfg->speaker_outs * 2; |
| 4632 | |
| 4633 | if (spec->multi_ios > 0) |
| 4634 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4635 | spec->const_channel_count); |
| 4636 | else |
| 4637 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4638 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4639 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4640 | alc_auto_parse_digital(codec); |
| 4641 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4642 | if (!spec->no_analog) |
| 4643 | alc_remove_invalid_adc_nids(codec); |
| 4644 | |
| 4645 | if (ssid_nids) |
| 4646 | alc_ssid_check(codec, ssid_nids); |
| 4647 | |
| 4648 | if (!spec->no_analog) { |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 4649 | err = alc_auto_check_switches(codec); |
| 4650 | if (err < 0) |
| 4651 | return err; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4652 | err = alc_auto_add_mic_boost(codec); |
| 4653 | if (err < 0) |
| 4654 | return err; |
| 4655 | } |
| 4656 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4657 | if (spec->kctls.list) |
| 4658 | add_mixer(spec, spec->kctls.list); |
| 4659 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4660 | if (!spec->no_analog && !spec->cap_mixer) |
| 4661 | set_capture_mixer(codec); |
| 4662 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4663 | return 1; |
| 4664 | } |
| 4665 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4666 | /* common preparation job for alc_spec */ |
| 4667 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4668 | { |
| 4669 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4670 | int err; |
| 4671 | |
| 4672 | if (!spec) |
| 4673 | return -ENOMEM; |
| 4674 | codec->spec = spec; |
Takashi Iwai | 1098b7c | 2012-12-17 20:03:15 +0100 | [diff] [blame] | 4675 | codec->single_adc_amp = 1; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4676 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 4677 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 4678 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 4679 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4680 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4681 | |
| 4682 | err = alc_codec_rename_from_preset(codec); |
| 4683 | if (err < 0) { |
| 4684 | kfree(spec); |
| 4685 | return err; |
| 4686 | } |
| 4687 | return 0; |
| 4688 | } |
| 4689 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4690 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4691 | { |
| 4692 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4693 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4694 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4695 | } |
| 4696 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4697 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4698 | * ALC880 fix-ups |
| 4699 | */ |
| 4700 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4701 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4702 | ALC880_FIXUP_GPIO2, |
| 4703 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4704 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4705 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4706 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4707 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4708 | ALC880_FIXUP_VOL_KNOB, |
| 4709 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4710 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4711 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4712 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4713 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4714 | ALC880_FIXUP_3ST_BASE, |
| 4715 | ALC880_FIXUP_3ST, |
| 4716 | ALC880_FIXUP_3ST_DIG, |
| 4717 | ALC880_FIXUP_5ST_BASE, |
| 4718 | ALC880_FIXUP_5ST, |
| 4719 | ALC880_FIXUP_5ST_DIG, |
| 4720 | ALC880_FIXUP_6ST_BASE, |
| 4721 | ALC880_FIXUP_6ST, |
| 4722 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4723 | }; |
| 4724 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4725 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4726 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4727 | const struct alc_fixup *fix, int action) |
| 4728 | { |
| 4729 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4730 | 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] | 4731 | } |
| 4732 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4733 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4734 | [ALC880_FIXUP_GPIO1] = { |
| 4735 | .type = ALC_FIXUP_VERBS, |
| 4736 | .v.verbs = alc_gpio1_init_verbs, |
| 4737 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4738 | [ALC880_FIXUP_GPIO2] = { |
| 4739 | .type = ALC_FIXUP_VERBS, |
| 4740 | .v.verbs = alc_gpio2_init_verbs, |
| 4741 | }, |
| 4742 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4743 | .type = ALC_FIXUP_VERBS, |
| 4744 | .v.verbs = (const struct hda_verb[]) { |
| 4745 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4746 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4747 | { } |
| 4748 | }, |
| 4749 | .chained = true, |
| 4750 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4751 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4752 | [ALC880_FIXUP_LG] = { |
| 4753 | .type = ALC_FIXUP_PINS, |
| 4754 | .v.pins = (const struct alc_pincfg[]) { |
| 4755 | /* disable bogus unused pins */ |
| 4756 | { 0x16, 0x411111f0 }, |
| 4757 | { 0x18, 0x411111f0 }, |
| 4758 | { 0x1a, 0x411111f0 }, |
| 4759 | { } |
| 4760 | } |
| 4761 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4762 | [ALC880_FIXUP_W810] = { |
| 4763 | .type = ALC_FIXUP_PINS, |
| 4764 | .v.pins = (const struct alc_pincfg[]) { |
| 4765 | /* disable bogus unused pins */ |
| 4766 | { 0x17, 0x411111f0 }, |
| 4767 | { } |
| 4768 | }, |
| 4769 | .chained = true, |
| 4770 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4771 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4772 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4773 | .type = ALC_FIXUP_VERBS, |
| 4774 | .v.verbs = (const struct hda_verb[]) { |
| 4775 | /* change to EAPD mode */ |
| 4776 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4777 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4778 | {} |
| 4779 | }, |
| 4780 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4781 | [ALC880_FIXUP_TCL_S700] = { |
| 4782 | .type = ALC_FIXUP_VERBS, |
| 4783 | .v.verbs = (const struct hda_verb[]) { |
| 4784 | /* change to EAPD mode */ |
| 4785 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4786 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4787 | {} |
| 4788 | }, |
| 4789 | .chained = true, |
| 4790 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4791 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4792 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4793 | .type = ALC_FIXUP_FUNC, |
| 4794 | .v.func = alc880_fixup_vol_knob, |
| 4795 | }, |
| 4796 | [ALC880_FIXUP_FUJITSU] = { |
| 4797 | /* override all pins as BIOS on old Amilo is broken */ |
| 4798 | .type = ALC_FIXUP_PINS, |
| 4799 | .v.pins = (const struct alc_pincfg[]) { |
| 4800 | { 0x14, 0x0121411f }, /* HP */ |
| 4801 | { 0x15, 0x99030120 }, /* speaker */ |
| 4802 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4803 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4804 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4805 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4806 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4807 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4808 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4809 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4810 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4811 | { } |
| 4812 | }, |
| 4813 | .chained = true, |
| 4814 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4815 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4816 | [ALC880_FIXUP_F1734] = { |
| 4817 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4818 | .type = ALC_FIXUP_PINS, |
| 4819 | .v.pins = (const struct alc_pincfg[]) { |
| 4820 | { 0x14, 0x0121411f }, /* HP */ |
| 4821 | { 0x15, 0x99030120 }, /* speaker */ |
| 4822 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4823 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4824 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4825 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4826 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4827 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4828 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4829 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4830 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4831 | { } |
| 4832 | }, |
| 4833 | .chained = true, |
| 4834 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4835 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4836 | [ALC880_FIXUP_UNIWILL] = { |
| 4837 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4838 | .type = ALC_FIXUP_PINS, |
| 4839 | .v.pins = (const struct alc_pincfg[]) { |
| 4840 | { 0x14, 0x0121411f }, /* HP */ |
| 4841 | { 0x15, 0x99030120 }, /* speaker */ |
| 4842 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4843 | { } |
| 4844 | }, |
| 4845 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4846 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4847 | .type = ALC_FIXUP_PINS, |
| 4848 | .v.pins = (const struct alc_pincfg[]) { |
| 4849 | /* disable bogus unused pins */ |
| 4850 | { 0x17, 0x411111f0 }, |
| 4851 | { 0x19, 0x411111f0 }, |
| 4852 | { 0x1b, 0x411111f0 }, |
| 4853 | { 0x1f, 0x411111f0 }, |
| 4854 | { } |
| 4855 | } |
| 4856 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4857 | [ALC880_FIXUP_Z71V] = { |
| 4858 | .type = ALC_FIXUP_PINS, |
| 4859 | .v.pins = (const struct alc_pincfg[]) { |
| 4860 | /* set up the whole pins as BIOS is utterly broken */ |
| 4861 | { 0x14, 0x99030120 }, /* speaker */ |
| 4862 | { 0x15, 0x0121411f }, /* HP */ |
| 4863 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4864 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4865 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4866 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4867 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4868 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4869 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4870 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4871 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4872 | { } |
| 4873 | } |
| 4874 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4875 | [ALC880_FIXUP_3ST_BASE] = { |
| 4876 | .type = ALC_FIXUP_PINS, |
| 4877 | .v.pins = (const struct alc_pincfg[]) { |
| 4878 | { 0x14, 0x01014010 }, /* line-out */ |
| 4879 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4880 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4881 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4882 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4883 | { 0x19, 0x0121411f }, /* HP */ |
| 4884 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4885 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4886 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4887 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4888 | /* 0x1e is filled in below */ |
| 4889 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4890 | { } |
| 4891 | } |
| 4892 | }, |
| 4893 | [ALC880_FIXUP_3ST] = { |
| 4894 | .type = ALC_FIXUP_PINS, |
| 4895 | .v.pins = (const struct alc_pincfg[]) { |
| 4896 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4897 | { } |
| 4898 | }, |
| 4899 | .chained = true, |
| 4900 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4901 | }, |
| 4902 | [ALC880_FIXUP_3ST_DIG] = { |
| 4903 | .type = ALC_FIXUP_PINS, |
| 4904 | .v.pins = (const struct alc_pincfg[]) { |
| 4905 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4906 | { } |
| 4907 | }, |
| 4908 | .chained = true, |
| 4909 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4910 | }, |
| 4911 | [ALC880_FIXUP_5ST_BASE] = { |
| 4912 | .type = ALC_FIXUP_PINS, |
| 4913 | .v.pins = (const struct alc_pincfg[]) { |
| 4914 | { 0x14, 0x01014010 }, /* front */ |
| 4915 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4916 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4917 | { 0x17, 0x01016412 }, /* surr */ |
| 4918 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4919 | { 0x19, 0x0121411f }, /* HP */ |
| 4920 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4921 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4922 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4923 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4924 | /* 0x1e is filled in below */ |
| 4925 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4926 | { } |
| 4927 | } |
| 4928 | }, |
| 4929 | [ALC880_FIXUP_5ST] = { |
| 4930 | .type = ALC_FIXUP_PINS, |
| 4931 | .v.pins = (const struct alc_pincfg[]) { |
| 4932 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4933 | { } |
| 4934 | }, |
| 4935 | .chained = true, |
| 4936 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4937 | }, |
| 4938 | [ALC880_FIXUP_5ST_DIG] = { |
| 4939 | .type = ALC_FIXUP_PINS, |
| 4940 | .v.pins = (const struct alc_pincfg[]) { |
| 4941 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4942 | { } |
| 4943 | }, |
| 4944 | .chained = true, |
| 4945 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4946 | }, |
| 4947 | [ALC880_FIXUP_6ST_BASE] = { |
| 4948 | .type = ALC_FIXUP_PINS, |
| 4949 | .v.pins = (const struct alc_pincfg[]) { |
| 4950 | { 0x14, 0x01014010 }, /* front */ |
| 4951 | { 0x15, 0x01016412 }, /* surr */ |
| 4952 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4953 | { 0x17, 0x01012414 }, /* side */ |
| 4954 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4955 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4956 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4957 | { 0x1b, 0x0121411f }, /* HP */ |
| 4958 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4959 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4960 | /* 0x1e is filled in below */ |
| 4961 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4962 | { } |
| 4963 | } |
| 4964 | }, |
| 4965 | [ALC880_FIXUP_6ST] = { |
| 4966 | .type = ALC_FIXUP_PINS, |
| 4967 | .v.pins = (const struct alc_pincfg[]) { |
| 4968 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4969 | { } |
| 4970 | }, |
| 4971 | .chained = true, |
| 4972 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4973 | }, |
| 4974 | [ALC880_FIXUP_6ST_DIG] = { |
| 4975 | .type = ALC_FIXUP_PINS, |
| 4976 | .v.pins = (const struct alc_pincfg[]) { |
| 4977 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4978 | { } |
| 4979 | }, |
| 4980 | .chained = true, |
| 4981 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4982 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4983 | }; |
| 4984 | |
| 4985 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4986 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4987 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4988 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4989 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4990 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4991 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4992 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4993 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4994 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4995 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4996 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4997 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4998 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4999 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 5000 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 5001 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 5002 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 5003 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 5004 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 5005 | |
| 5006 | /* Below is the copied entries from alc880_quirks.c. |
| 5007 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 5008 | * on these machines, thus they are kept to be compatible with |
| 5009 | * the old static quirks. Once when it's confirmed to work without |
| 5010 | * these overrides, it'd be better to remove. |
| 5011 | */ |
| 5012 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 5013 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 5014 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 5015 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 5016 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 5017 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 5018 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 5019 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 5020 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 5021 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 5022 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 5023 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 5024 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 5025 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 5026 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 5027 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 5028 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 5029 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 5030 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 5031 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 5032 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 5033 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 5034 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 5035 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5036 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5037 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5038 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 5039 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5040 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 5041 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 5042 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5043 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5044 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5045 | /* default Intel */ |
| 5046 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 5047 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 5048 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 5049 | {} |
| 5050 | }; |
| 5051 | |
| 5052 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 5053 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 5054 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 5055 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 5056 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 5057 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 5058 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 5059 | {} |
| 5060 | }; |
| 5061 | |
| 5062 | |
| 5063 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5064 | * OK, here we have finally the patch for ALC880 |
| 5065 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5066 | static int patch_alc880(struct hda_codec *codec) |
| 5067 | { |
| 5068 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5069 | int err; |
| 5070 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5071 | err = alc_alloc_spec(codec, 0x0b); |
| 5072 | if (err < 0) |
| 5073 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5074 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5075 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 5076 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5077 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 5078 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 5079 | alc880_fixups); |
| 5080 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5081 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 5082 | /* automatic parse from the BIOS config */ |
| 5083 | err = alc880_parse_auto_config(codec); |
| 5084 | if (err < 0) |
| 5085 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5086 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5087 | if (!spec->no_analog) { |
| 5088 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5089 | if (err < 0) |
| 5090 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5091 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 5092 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5093 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5094 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5095 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 5096 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5097 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5098 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5099 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5100 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5101 | |
| 5102 | error: |
| 5103 | alc_free(codec); |
| 5104 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5105 | } |
| 5106 | |
| 5107 | |
| 5108 | /* |
| 5109 | * ALC260 support |
| 5110 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5111 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 5112 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5113 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5114 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 5115 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5116 | } |
| 5117 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5118 | /* |
| 5119 | * Pin config fixes |
| 5120 | */ |
| 5121 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5122 | ALC260_FIXUP_HP_DC5750, |
| 5123 | ALC260_FIXUP_HP_PIN_0F, |
| 5124 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5125 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5126 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 5127 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5128 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5129 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5130 | }; |
| 5131 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5132 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 5133 | { |
| 5134 | struct alc_spec *spec = codec->spec; |
| 5135 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 5136 | spec->hp_jack_present); |
| 5137 | } |
| 5138 | |
| 5139 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 5140 | const struct alc_fixup *fix, int action) |
| 5141 | { |
| 5142 | struct alc_spec *spec = codec->spec; |
| 5143 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 5144 | /* although the machine has only one output pin, we need to |
| 5145 | * toggle GPIO1 according to the jack state |
| 5146 | */ |
| 5147 | spec->automute_hook = alc260_gpio1_automute; |
| 5148 | spec->detect_hp = 1; |
| 5149 | spec->automute_speaker = 1; |
| 5150 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5151 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 5152 | alc_hp_automute); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5153 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5154 | } |
| 5155 | } |
| 5156 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5157 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 5158 | const struct alc_fixup *fix, int action) |
| 5159 | { |
| 5160 | struct alc_spec *spec = codec->spec; |
| 5161 | static const struct alc_pincfg pincfgs[] = { |
| 5162 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 5163 | { 0x12, 0x90a60160 }, /* int mic */ |
| 5164 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 5165 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 5166 | /* disable bogus I/O pins */ |
| 5167 | { 0x10, 0x411111f0 }, |
| 5168 | { 0x11, 0x411111f0 }, |
| 5169 | { 0x14, 0x411111f0 }, |
| 5170 | { 0x15, 0x411111f0 }, |
| 5171 | { 0x16, 0x411111f0 }, |
| 5172 | { 0x17, 0x411111f0 }, |
| 5173 | { 0x19, 0x411111f0 }, |
| 5174 | { } |
| 5175 | }; |
| 5176 | |
| 5177 | switch (action) { |
| 5178 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 5179 | alc_apply_pincfgs(codec, pincfgs); |
| 5180 | break; |
| 5181 | case ALC_FIXUP_ACT_PROBE: |
| 5182 | spec->init_amp = ALC_INIT_NONE; |
| 5183 | break; |
| 5184 | } |
| 5185 | } |
| 5186 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5187 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5188 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5189 | .type = ALC_FIXUP_PINS, |
| 5190 | .v.pins = (const struct alc_pincfg[]) { |
| 5191 | { 0x11, 0x90130110 }, /* speaker */ |
| 5192 | { } |
| 5193 | } |
| 5194 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5195 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 5196 | .type = ALC_FIXUP_PINS, |
| 5197 | .v.pins = (const struct alc_pincfg[]) { |
| 5198 | { 0x0f, 0x01214000 }, /* HP */ |
| 5199 | { } |
| 5200 | } |
| 5201 | }, |
| 5202 | [ALC260_FIXUP_COEF] = { |
| 5203 | .type = ALC_FIXUP_VERBS, |
| 5204 | .v.verbs = (const struct hda_verb[]) { |
| 5205 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5206 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 5207 | { } |
| 5208 | }, |
| 5209 | .chained = true, |
| 5210 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5211 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5212 | [ALC260_FIXUP_GPIO1] = { |
| 5213 | .type = ALC_FIXUP_VERBS, |
| 5214 | .v.verbs = alc_gpio1_init_verbs, |
| 5215 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5216 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 5217 | .type = ALC_FIXUP_FUNC, |
| 5218 | .v.func = alc260_fixup_gpio1_toggle, |
| 5219 | .chained = true, |
| 5220 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5221 | }, |
| 5222 | [ALC260_FIXUP_REPLACER] = { |
| 5223 | .type = ALC_FIXUP_VERBS, |
| 5224 | .v.verbs = (const struct hda_verb[]) { |
| 5225 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5226 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5227 | { } |
| 5228 | }, |
| 5229 | .chained = true, |
| 5230 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 5231 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5232 | [ALC260_FIXUP_HP_B1900] = { |
| 5233 | .type = ALC_FIXUP_FUNC, |
| 5234 | .v.func = alc260_fixup_gpio1_toggle, |
| 5235 | .chained = true, |
| 5236 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5237 | }, |
| 5238 | [ALC260_FIXUP_KN1] = { |
| 5239 | .type = ALC_FIXUP_FUNC, |
| 5240 | .v.func = alc260_fixup_kn1, |
| 5241 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5242 | }; |
| 5243 | |
| 5244 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5245 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5246 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5247 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5248 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5249 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 5250 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5251 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5252 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5253 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5254 | {} |
| 5255 | }; |
| 5256 | |
| 5257 | /* |
| 5258 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5259 | static int patch_alc260(struct hda_codec *codec) |
| 5260 | { |
| 5261 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5262 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5263 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5264 | err = alc_alloc_spec(codec, 0x07); |
| 5265 | if (err < 0) |
| 5266 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5267 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5268 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5269 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5270 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5271 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5272 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5273 | /* automatic parse from the BIOS config */ |
| 5274 | err = alc260_parse_auto_config(codec); |
| 5275 | if (err < 0) |
| 5276 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5277 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5278 | if (!spec->no_analog) { |
| 5279 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5280 | if (err < 0) |
| 5281 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5282 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5283 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5284 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5285 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5286 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5287 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5288 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5289 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5290 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5291 | |
| 5292 | error: |
| 5293 | alc_free(codec); |
| 5294 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5295 | } |
| 5296 | |
| 5297 | |
| 5298 | /* |
| 5299 | * ALC882/883/885/888/889 support |
| 5300 | * |
| 5301 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5302 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5303 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5304 | * 6-channel independent captures. |
| 5305 | * |
| 5306 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5307 | * driver yet). |
| 5308 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5309 | |
| 5310 | /* |
| 5311 | * Pin config fixes |
| 5312 | */ |
| 5313 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5314 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5315 | ALC882_FIXUP_LENOVO_Y530, |
| 5316 | ALC882_FIXUP_PB_M5210, |
| 5317 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5318 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5319 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5320 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5321 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5322 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5323 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5324 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5325 | ALC882_FIXUP_GPIO1, |
| 5326 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5327 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5328 | ALC889_FIXUP_COEF, |
| 5329 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5330 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5331 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5332 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5333 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5334 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5335 | ALC889_FIXUP_MBP_VREF, |
| 5336 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5337 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5338 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5339 | }; |
| 5340 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5341 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5342 | const struct alc_fixup *fix, int action) |
| 5343 | { |
| 5344 | if (action != ALC_FIXUP_ACT_INIT) |
| 5345 | return; |
| 5346 | alc889_coef_init(codec); |
| 5347 | } |
| 5348 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5349 | /* toggle speaker-output according to the hp-jack state */ |
| 5350 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5351 | { |
| 5352 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5353 | |
| 5354 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5355 | AC_VERB_GET_GPIO_DATA, 0); |
| 5356 | |
| 5357 | if (!muted) |
| 5358 | gpiostate |= (1 << pin); |
| 5359 | else |
| 5360 | gpiostate &= ~(1 << pin); |
| 5361 | |
| 5362 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5363 | AC_VERB_GET_GPIO_MASK, 0); |
| 5364 | gpiomask |= (1 << pin); |
| 5365 | |
| 5366 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5367 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5368 | gpiodir |= (1 << pin); |
| 5369 | |
| 5370 | |
| 5371 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5372 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5373 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5374 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5375 | |
| 5376 | msleep(1); |
| 5377 | |
| 5378 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5379 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5380 | } |
| 5381 | |
| 5382 | /* set up GPIO at initialization */ |
| 5383 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5384 | const struct alc_fixup *fix, int action) |
| 5385 | { |
| 5386 | if (action != ALC_FIXUP_ACT_INIT) |
| 5387 | return; |
| 5388 | alc882_gpio_mute(codec, 0, 0); |
| 5389 | alc882_gpio_mute(codec, 1, 0); |
| 5390 | } |
| 5391 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5392 | /* Fix the connection of some pins for ALC889: |
| 5393 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5394 | * work correctly (bko#42740) |
| 5395 | */ |
| 5396 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5397 | const struct alc_fixup *fix, int action) |
| 5398 | { |
| 5399 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5400 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5401 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5402 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5403 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5404 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5405 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5406 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5407 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5408 | /* restore the connections */ |
| 5409 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5410 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5411 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5412 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5413 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5414 | } |
| 5415 | } |
| 5416 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5417 | /* Set VREF on HP pin */ |
| 5418 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5419 | const struct alc_fixup *fix, int action) |
| 5420 | { |
| 5421 | struct alc_spec *spec = codec->spec; |
| 5422 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5423 | int i; |
| 5424 | |
| 5425 | if (action != ALC_FIXUP_ACT_INIT) |
| 5426 | return; |
| 5427 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5428 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5429 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5430 | continue; |
| 5431 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5432 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5433 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5434 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5435 | spec->keep_vref_in_automute = 1; |
| 5436 | break; |
| 5437 | } |
| 5438 | } |
| 5439 | |
| 5440 | /* Set VREF on speaker pins on imac91 */ |
| 5441 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5442 | const struct alc_fixup *fix, int action) |
| 5443 | { |
| 5444 | struct alc_spec *spec = codec->spec; |
| 5445 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5446 | int i; |
| 5447 | |
| 5448 | if (action != ALC_FIXUP_ACT_INIT) |
| 5449 | return; |
| 5450 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5451 | unsigned int val; |
| 5452 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5453 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5454 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5455 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5456 | } |
| 5457 | spec->keep_vref_in_automute = 1; |
| 5458 | } |
| 5459 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5460 | /* Don't take HP output as primary |
| 5461 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5462 | */ |
| 5463 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5464 | const struct alc_fixup *fix, int action) |
| 5465 | { |
| 5466 | struct alc_spec *spec = codec->spec; |
| 5467 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5468 | spec->no_primary_hp = 1; |
| 5469 | } |
| 5470 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5471 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5472 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5473 | .type = ALC_FIXUP_PINS, |
| 5474 | .v.pins = (const struct alc_pincfg[]) { |
| 5475 | { 0x15, 0x01080104 }, /* side */ |
| 5476 | { 0x16, 0x01011012 }, /* rear */ |
| 5477 | { 0x17, 0x01016011 }, /* clfe */ |
| 5478 | { } |
| 5479 | } |
| 5480 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5481 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5482 | .type = ALC_FIXUP_PINS, |
| 5483 | .v.pins = (const struct alc_pincfg[]) { |
| 5484 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5485 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5486 | { } |
| 5487 | } |
| 5488 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5489 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5490 | .type = ALC_FIXUP_VERBS, |
| 5491 | .v.verbs = (const struct hda_verb[]) { |
| 5492 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5493 | {} |
| 5494 | } |
| 5495 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5496 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5497 | .type = ALC_FIXUP_FUNC, |
| 5498 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5499 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5500 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5501 | .type = ALC_FIXUP_PINS, |
| 5502 | .v.pins = (const struct alc_pincfg[]) { |
| 5503 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5504 | { } |
| 5505 | } |
| 5506 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5507 | [ALC889_FIXUP_CD] = { |
| 5508 | .type = ALC_FIXUP_PINS, |
| 5509 | .v.pins = (const struct alc_pincfg[]) { |
| 5510 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5511 | { } |
| 5512 | } |
| 5513 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5514 | [ALC889_FIXUP_VAIO_TT] = { |
| 5515 | .type = ALC_FIXUP_PINS, |
| 5516 | .v.pins = (const struct alc_pincfg[]) { |
| 5517 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5518 | { } |
| 5519 | } |
| 5520 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5521 | [ALC888_FIXUP_EEE1601] = { |
| 5522 | .type = ALC_FIXUP_VERBS, |
| 5523 | .v.verbs = (const struct hda_verb[]) { |
| 5524 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5525 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5526 | { } |
| 5527 | } |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5528 | }, |
| 5529 | [ALC882_FIXUP_EAPD] = { |
| 5530 | .type = ALC_FIXUP_VERBS, |
| 5531 | .v.verbs = (const struct hda_verb[]) { |
| 5532 | /* change to EAPD mode */ |
| 5533 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5534 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5535 | { } |
| 5536 | } |
| 5537 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5538 | [ALC883_FIXUP_EAPD] = { |
| 5539 | .type = ALC_FIXUP_VERBS, |
| 5540 | .v.verbs = (const struct hda_verb[]) { |
| 5541 | /* change to EAPD mode */ |
| 5542 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5543 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5544 | { } |
| 5545 | } |
| 5546 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5547 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5548 | .type = ALC_FIXUP_VERBS, |
| 5549 | .v.verbs = (const struct hda_verb[]) { |
| 5550 | /* eanable EAPD on Acer laptops */ |
| 5551 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5552 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5553 | { } |
| 5554 | } |
| 5555 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5556 | [ALC882_FIXUP_GPIO1] = { |
| 5557 | .type = ALC_FIXUP_VERBS, |
| 5558 | .v.verbs = alc_gpio1_init_verbs, |
| 5559 | }, |
| 5560 | [ALC882_FIXUP_GPIO2] = { |
| 5561 | .type = ALC_FIXUP_VERBS, |
| 5562 | .v.verbs = alc_gpio2_init_verbs, |
| 5563 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5564 | [ALC882_FIXUP_GPIO3] = { |
| 5565 | .type = ALC_FIXUP_VERBS, |
| 5566 | .v.verbs = alc_gpio3_init_verbs, |
| 5567 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5568 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5569 | .type = ALC_FIXUP_VERBS, |
| 5570 | .v.verbs = alc_gpio1_init_verbs, |
| 5571 | .chained = true, |
| 5572 | .chain_id = ALC882_FIXUP_EAPD, |
| 5573 | }, |
| 5574 | [ALC889_FIXUP_COEF] = { |
| 5575 | .type = ALC_FIXUP_FUNC, |
| 5576 | .v.func = alc889_fixup_coef, |
| 5577 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5578 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5579 | .type = ALC_FIXUP_PINS, |
| 5580 | .v.pins = (const struct alc_pincfg[]) { |
| 5581 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5582 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5583 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5584 | }, |
| 5585 | .chained = true, |
| 5586 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5587 | }, |
| 5588 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5589 | .type = ALC_FIXUP_PINS, |
| 5590 | .v.pins = (const struct alc_pincfg[]) { |
| 5591 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5592 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5593 | { } |
| 5594 | }, |
| 5595 | .chained = true, |
| 5596 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5597 | }, |
| 5598 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5599 | /* additional init verbs for Acer Aspire 8930G */ |
| 5600 | .type = ALC_FIXUP_VERBS, |
| 5601 | .v.verbs = (const struct hda_verb[]) { |
| 5602 | /* Enable all DACs */ |
| 5603 | /* DAC DISABLE/MUTE 1? */ |
| 5604 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5605 | * apparently. Init=0x38 */ |
| 5606 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5607 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5608 | /* DAC DISABLE/MUTE 2? */ |
| 5609 | /* some bit here disables the other DACs. |
| 5610 | * Init=0x4900 */ |
| 5611 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5612 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5613 | /* DMIC fix |
| 5614 | * This laptop has a stereo digital microphone. |
| 5615 | * The mics are only 1cm apart which makes the stereo |
| 5616 | * useless. However, either the mic or the ALC889 |
| 5617 | * makes the signal become a difference/sum signal |
| 5618 | * instead of standard stereo, which is annoying. |
| 5619 | * So instead we flip this bit which makes the |
| 5620 | * codec replicate the sum signal to both channels, |
| 5621 | * turning it into a normal mono mic. |
| 5622 | */ |
| 5623 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5624 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5625 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5626 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5627 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5628 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5629 | }, |
| 5630 | .chained = true, |
| 5631 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5632 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5633 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5634 | .type = ALC_FIXUP_FUNC, |
| 5635 | .v.func = alc885_fixup_macpro_gpio, |
| 5636 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5637 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5638 | .type = ALC_FIXUP_FUNC, |
| 5639 | .v.func = alc889_fixup_dac_route, |
| 5640 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5641 | [ALC889_FIXUP_MBP_VREF] = { |
| 5642 | .type = ALC_FIXUP_FUNC, |
| 5643 | .v.func = alc889_fixup_mbp_vref, |
| 5644 | .chained = true, |
| 5645 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5646 | }, |
| 5647 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5648 | .type = ALC_FIXUP_FUNC, |
| 5649 | .v.func = alc889_fixup_imac91_vref, |
| 5650 | .chained = true, |
| 5651 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5652 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5653 | [ALC882_FIXUP_INV_DMIC] = { |
| 5654 | .type = ALC_FIXUP_FUNC, |
| 5655 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5656 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5657 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5658 | .type = ALC_FIXUP_FUNC, |
| 5659 | .v.func = alc882_fixup_no_primary_hp, |
| 5660 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5661 | }; |
| 5662 | |
| 5663 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5664 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5665 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5666 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5667 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5668 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5669 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5670 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5671 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5672 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5673 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5674 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5675 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5676 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5677 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5678 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5679 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5680 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5681 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5682 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5683 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5684 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5685 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5686 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5687 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5688 | 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] | 5689 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5690 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5691 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5692 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5693 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5694 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5695 | 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] | 5696 | |
| 5697 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5698 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5699 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5700 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5701 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5702 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5703 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5704 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5705 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5706 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5707 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5708 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5709 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5710 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5711 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5712 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5713 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5714 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5715 | 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] | 5716 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5717 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5718 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5719 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5720 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5721 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5722 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5723 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5724 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5725 | 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] | 5726 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5727 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5728 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5729 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5730 | {} |
| 5731 | }; |
| 5732 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5733 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5734 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5735 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5736 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5737 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5738 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5739 | {} |
| 5740 | }; |
| 5741 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5742 | /* |
| 5743 | * BIOS auto configuration |
| 5744 | */ |
| 5745 | /* almost identical with ALC880 parser... */ |
| 5746 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5747 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5748 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5749 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5750 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5751 | } |
| 5752 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5753 | /* |
| 5754 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5755 | static int patch_alc882(struct hda_codec *codec) |
| 5756 | { |
| 5757 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5758 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5759 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5760 | err = alc_alloc_spec(codec, 0x0b); |
| 5761 | if (err < 0) |
| 5762 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5763 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5764 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5765 | |
| 5766 | switch (codec->vendor_id) { |
| 5767 | case 0x10ec0882: |
| 5768 | case 0x10ec0885: |
| 5769 | break; |
| 5770 | default: |
| 5771 | /* ALC883 and variants */ |
| 5772 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5773 | break; |
| 5774 | } |
| 5775 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5776 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5777 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5778 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5779 | |
| 5780 | alc_auto_parse_customize_define(codec); |
| 5781 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5782 | /* automatic parse from the BIOS config */ |
| 5783 | err = alc882_parse_auto_config(codec); |
| 5784 | if (err < 0) |
| 5785 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5786 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5787 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5788 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5789 | if (err < 0) |
| 5790 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5791 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5792 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5793 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5794 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5795 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5796 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5797 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5798 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5799 | |
| 5800 | error: |
| 5801 | alc_free(codec); |
| 5802 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5803 | } |
| 5804 | |
| 5805 | |
| 5806 | /* |
| 5807 | * ALC262 support |
| 5808 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5809 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5810 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5811 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5812 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5813 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5814 | } |
| 5815 | |
| 5816 | /* |
| 5817 | * Pin config fixes |
| 5818 | */ |
| 5819 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5820 | ALC262_FIXUP_FSC_H270, |
| 5821 | ALC262_FIXUP_HP_Z200, |
| 5822 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5823 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5824 | ALC262_FIXUP_BENQ, |
| 5825 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5826 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5827 | }; |
| 5828 | |
| 5829 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5830 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5831 | .type = ALC_FIXUP_PINS, |
| 5832 | .v.pins = (const struct alc_pincfg[]) { |
| 5833 | { 0x14, 0x99130110 }, /* speaker */ |
| 5834 | { 0x15, 0x0221142f }, /* front HP */ |
| 5835 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5836 | { } |
| 5837 | } |
| 5838 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5839 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5840 | .type = ALC_FIXUP_PINS, |
| 5841 | .v.pins = (const struct alc_pincfg[]) { |
| 5842 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5843 | { } |
| 5844 | } |
| 5845 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5846 | [ALC262_FIXUP_TYAN] = { |
| 5847 | .type = ALC_FIXUP_PINS, |
| 5848 | .v.pins = (const struct alc_pincfg[]) { |
| 5849 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5850 | { } |
| 5851 | } |
| 5852 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5853 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5854 | .type = ALC_FIXUP_VERBS, |
| 5855 | .v.verbs = (const struct hda_verb[]) { |
| 5856 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5857 | {} |
| 5858 | }, |
| 5859 | .chained = true, |
| 5860 | .chain_id = ALC262_FIXUP_BENQ, |
| 5861 | }, |
| 5862 | [ALC262_FIXUP_BENQ] = { |
| 5863 | .type = ALC_FIXUP_VERBS, |
| 5864 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5865 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5866 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5867 | {} |
| 5868 | } |
| 5869 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5870 | [ALC262_FIXUP_BENQ_T31] = { |
| 5871 | .type = ALC_FIXUP_VERBS, |
| 5872 | .v.verbs = (const struct hda_verb[]) { |
| 5873 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5874 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5875 | {} |
| 5876 | } |
| 5877 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5878 | [ALC262_FIXUP_INV_DMIC] = { |
| 5879 | .type = ALC_FIXUP_FUNC, |
| 5880 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5881 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5882 | }; |
| 5883 | |
| 5884 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5885 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5886 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5887 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5888 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5889 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5890 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5891 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5892 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5893 | {} |
| 5894 | }; |
| 5895 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5896 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5897 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5898 | {} |
| 5899 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5900 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5901 | /* |
| 5902 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5903 | static int patch_alc262(struct hda_codec *codec) |
| 5904 | { |
| 5905 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5906 | int err; |
| 5907 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5908 | err = alc_alloc_spec(codec, 0x0b); |
| 5909 | if (err < 0) |
| 5910 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5911 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5912 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5913 | |
| 5914 | #if 0 |
| 5915 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5916 | * under-run |
| 5917 | */ |
| 5918 | { |
| 5919 | int tmp; |
| 5920 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5921 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5922 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5923 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5924 | } |
| 5925 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5926 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5927 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5928 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5929 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5930 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5931 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5932 | alc_auto_parse_customize_define(codec); |
| 5933 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5934 | /* automatic parse from the BIOS config */ |
| 5935 | err = alc262_parse_auto_config(codec); |
| 5936 | if (err < 0) |
| 5937 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5938 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5939 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5940 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5941 | if (err < 0) |
| 5942 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5943 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5944 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5945 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5946 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5947 | spec->shutup = alc_eapd_shutup; |
| 5948 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5949 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5950 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5951 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5952 | |
| 5953 | error: |
| 5954 | alc_free(codec); |
| 5955 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5956 | } |
| 5957 | |
| 5958 | /* |
| 5959 | * ALC268 |
| 5960 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5961 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5962 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5963 | .ops = &snd_hda_bind_sw, |
| 5964 | .values = { |
| 5965 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5966 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5967 | 0 |
| 5968 | }, |
| 5969 | }; |
| 5970 | |
| 5971 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5972 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5973 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5974 | { } |
| 5975 | }; |
| 5976 | |
| 5977 | /* set PCBEEP vol = 0, mute connections */ |
| 5978 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5979 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5980 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5981 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5982 | { } |
| 5983 | }; |
| 5984 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5985 | enum { |
| 5986 | ALC268_FIXUP_INV_DMIC, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5987 | ALC268_FIXUP_HP_EAPD, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5988 | }; |
| 5989 | |
| 5990 | static const struct alc_fixup alc268_fixups[] = { |
| 5991 | [ALC268_FIXUP_INV_DMIC] = { |
| 5992 | .type = ALC_FIXUP_FUNC, |
| 5993 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5994 | }, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5995 | [ALC268_FIXUP_HP_EAPD] = { |
| 5996 | .type = ALC_FIXUP_VERBS, |
| 5997 | .v.verbs = (const struct hda_verb[]) { |
| 5998 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5999 | {} |
| 6000 | } |
| 6001 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6002 | }; |
| 6003 | |
| 6004 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 6005 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 6006 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
| 6007 | {} |
| 6008 | }; |
| 6009 | |
| 6010 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 6011 | /* below is codec SSID since multiple Toshiba laptops have the |
| 6012 | * same PCI SSID 1179:ff00 |
| 6013 | */ |
| 6014 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6015 | {} |
| 6016 | }; |
| 6017 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6018 | /* |
| 6019 | * BIOS auto configuration |
| 6020 | */ |
| 6021 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 6022 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6023 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6024 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6025 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 6026 | if (err > 0) { |
| 6027 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 6028 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6029 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6030 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6031 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6032 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6033 | } |
| 6034 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6035 | /* |
| 6036 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6037 | static int patch_alc268(struct hda_codec *codec) |
| 6038 | { |
| 6039 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6040 | int i, has_beep, err; |
| 6041 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6042 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6043 | err = alc_alloc_spec(codec, 0); |
| 6044 | if (err < 0) |
| 6045 | return err; |
| 6046 | |
| 6047 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6048 | |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 6049 | alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6050 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6051 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 6052 | /* automatic parse from the BIOS config */ |
| 6053 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6054 | if (err < 0) |
| 6055 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6056 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6057 | has_beep = 0; |
| 6058 | for (i = 0; i < spec->num_mixers; i++) { |
| 6059 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 6060 | has_beep = 1; |
| 6061 | break; |
| 6062 | } |
| 6063 | } |
| 6064 | |
| 6065 | if (has_beep) { |
| 6066 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6067 | if (err < 0) |
| 6068 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6069 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 6070 | /* override the amp caps for beep generator */ |
| 6071 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 6072 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 6073 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6074 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6075 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 6076 | } |
| 6077 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6078 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6079 | spec->shutup = alc_eapd_shutup; |
| 6080 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6081 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6082 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6083 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6084 | |
| 6085 | error: |
| 6086 | alc_free(codec); |
| 6087 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6088 | } |
| 6089 | |
| 6090 | /* |
| 6091 | * ALC269 |
| 6092 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6093 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 6094 | .substreams = 1, |
| 6095 | .channels_min = 2, |
| 6096 | .channels_max = 8, |
| 6097 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 6098 | /* NID is set in alc_build_pcms */ |
| 6099 | .ops = { |
| 6100 | .open = alc_playback_pcm_open, |
| 6101 | .prepare = alc_playback_pcm_prepare, |
| 6102 | .cleanup = alc_playback_pcm_cleanup |
| 6103 | }, |
| 6104 | }; |
| 6105 | |
| 6106 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 6107 | .substreams = 1, |
| 6108 | .channels_min = 2, |
| 6109 | .channels_max = 2, |
| 6110 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 6111 | /* NID is set in alc_build_pcms */ |
| 6112 | }; |
| 6113 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6114 | /* different alc269-variants */ |
| 6115 | enum { |
| 6116 | ALC269_TYPE_ALC269VA, |
| 6117 | ALC269_TYPE_ALC269VB, |
| 6118 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6119 | ALC269_TYPE_ALC269VD, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6120 | ALC269_TYPE_ALC280, |
| 6121 | ALC269_TYPE_ALC282, |
| 6122 | ALC269_TYPE_ALC284, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6123 | }; |
| 6124 | |
| 6125 | /* |
| 6126 | * BIOS auto configuration |
| 6127 | */ |
| 6128 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 6129 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6130 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6131 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 6132 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6133 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6134 | const hda_nid_t *ssids; |
| 6135 | |
| 6136 | switch (spec->codec_variant) { |
| 6137 | case ALC269_TYPE_ALC269VA: |
| 6138 | case ALC269_TYPE_ALC269VC: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6139 | case ALC269_TYPE_ALC280: |
| 6140 | case ALC269_TYPE_ALC284: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6141 | ssids = alc269va_ssids; |
| 6142 | break; |
| 6143 | case ALC269_TYPE_ALC269VB: |
| 6144 | case ALC269_TYPE_ALC269VD: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6145 | case ALC269_TYPE_ALC282: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6146 | ssids = alc269_ssids; |
| 6147 | break; |
| 6148 | default: |
| 6149 | ssids = alc269_ssids; |
| 6150 | break; |
| 6151 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6152 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6153 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6154 | } |
| 6155 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6156 | 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] | 6157 | { |
| 6158 | int val = alc_read_coef_idx(codec, 0x04); |
| 6159 | if (power_up) |
| 6160 | val |= 1 << 11; |
| 6161 | else |
| 6162 | val &= ~(1 << 11); |
| 6163 | alc_write_coef_idx(codec, 0x04, val); |
| 6164 | } |
| 6165 | |
| 6166 | static void alc269_shutup(struct hda_codec *codec) |
| 6167 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6168 | struct alc_spec *spec = codec->spec; |
| 6169 | |
| 6170 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 6171 | return; |
| 6172 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6173 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6174 | alc269vb_toggle_power_output(codec, 0); |
| 6175 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
| 6176 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6177 | msleep(150); |
| 6178 | } |
| 6179 | } |
| 6180 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6181 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6182 | static int alc269_resume(struct hda_codec *codec) |
| 6183 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6184 | struct alc_spec *spec = codec->spec; |
| 6185 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6186 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6187 | alc269vb_toggle_power_output(codec, 0); |
| 6188 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6189 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6190 | msleep(150); |
| 6191 | } |
| 6192 | |
| 6193 | codec->patch_ops.init(codec); |
| 6194 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6195 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6196 | alc269vb_toggle_power_output(codec, 1); |
| 6197 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6198 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6199 | msleep(200); |
| 6200 | } |
| 6201 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6202 | snd_hda_codec_resume_amp(codec); |
| 6203 | snd_hda_codec_resume_cache(codec); |
| 6204 | hda_call_check_power_status(codec, 0x01); |
| 6205 | return 0; |
| 6206 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6207 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6208 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6209 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 6210 | const struct alc_fixup *fix, int action) |
| 6211 | { |
| 6212 | struct alc_spec *spec = codec->spec; |
| 6213 | |
| 6214 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6215 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6216 | } |
| 6217 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6218 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 6219 | const struct alc_fixup *fix, int action) |
| 6220 | { |
| 6221 | int coef; |
| 6222 | |
| 6223 | if (action != ALC_FIXUP_ACT_INIT) |
| 6224 | return; |
| 6225 | coef = alc_read_coef_idx(codec, 0x1e); |
| 6226 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 6227 | } |
| 6228 | |
| 6229 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 6230 | const struct alc_fixup *fix, int action) |
| 6231 | { |
| 6232 | static const struct hda_verb verbs[] = { |
| 6233 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 6234 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 6235 | {} |
| 6236 | }; |
| 6237 | unsigned int cfg; |
| 6238 | |
| 6239 | if (strcmp(codec->chip_name, "ALC271X")) |
| 6240 | return; |
| 6241 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 6242 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 6243 | snd_hda_sequence_write(codec, verbs); |
| 6244 | } |
| 6245 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6246 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 6247 | const struct alc_fixup *fix, int action) |
| 6248 | { |
| 6249 | struct alc_spec *spec = codec->spec; |
| 6250 | |
| 6251 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6252 | return; |
| 6253 | |
| 6254 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 6255 | * fix the sample rate of analog I/O to 44.1kHz |
| 6256 | */ |
| 6257 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 6258 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 6259 | } |
| 6260 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6261 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 6262 | const struct alc_fixup *fix, int action) |
| 6263 | { |
| 6264 | int coef; |
| 6265 | |
| 6266 | if (action != ALC_FIXUP_ACT_INIT) |
| 6267 | return; |
| 6268 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 6269 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 6270 | * Below is a workaround specific to ALC269 to control the dmic |
| 6271 | * signal source as mono. |
| 6272 | */ |
| 6273 | coef = alc_read_coef_idx(codec, 0x07); |
| 6274 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 6275 | } |
| 6276 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6277 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 6278 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 6279 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6280 | |
| 6281 | snd_hda_codec_write(codec, 0x20, 0, |
| 6282 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6283 | snd_hda_codec_write(codec, 0x20, 0, |
| 6284 | AC_VERB_SET_PROC_COEF, 0x680); |
| 6285 | |
| 6286 | snd_hda_codec_write(codec, 0x20, 0, |
| 6287 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6288 | snd_hda_codec_write(codec, 0x20, 0, |
| 6289 | AC_VERB_SET_PROC_COEF, 0x480); |
| 6290 | } |
| 6291 | |
| 6292 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 6293 | const struct alc_fixup *fix, int action) |
| 6294 | { |
| 6295 | struct alc_spec *spec = codec->spec; |
| 6296 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6297 | return; |
| 6298 | spec->automute_hook = alc269_quanta_automute; |
| 6299 | } |
| 6300 | |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6301 | /* update mute-LED according to the speaker mute state via mic1 VREF pin */ |
| 6302 | static void alc269_fixup_mic1_mute_hook(void *private_data, int enabled) |
| 6303 | { |
| 6304 | struct hda_codec *codec = private_data; |
| 6305 | unsigned int pinval = AC_PINCTL_IN_EN + (enabled ? |
| 6306 | AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); |
| 6307 | snd_hda_set_pin_ctl_cache(codec, 0x18, pinval); |
| 6308 | } |
| 6309 | |
| 6310 | static void alc269_fixup_mic1_mute(struct hda_codec *codec, |
| 6311 | const struct alc_fixup *fix, int action) |
| 6312 | { |
| 6313 | struct alc_spec *spec = codec->spec; |
| 6314 | switch (action) { |
| 6315 | case ALC_FIXUP_ACT_BUILD: |
| 6316 | spec->vmaster_mute.hook = alc269_fixup_mic1_mute_hook; |
| 6317 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
| 6318 | /* fallthru */ |
| 6319 | case ALC_FIXUP_ACT_INIT: |
| 6320 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 6321 | break; |
| 6322 | } |
| 6323 | } |
| 6324 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6325 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 6326 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 6327 | { |
| 6328 | struct hda_codec *codec = private_data; |
| 6329 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6330 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6331 | } |
| 6332 | |
| 6333 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 6334 | const struct alc_fixup *fix, int action) |
| 6335 | { |
| 6336 | struct alc_spec *spec = codec->spec; |
| 6337 | switch (action) { |
| 6338 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6339 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735cb | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 6340 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6341 | /* fallthru */ |
| 6342 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6343 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6344 | break; |
| 6345 | } |
| 6346 | } |
| 6347 | |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6348 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
| 6349 | const struct alc_fixup *fix, |
| 6350 | int action) |
| 6351 | { |
| 6352 | struct alc_spec *spec = codec->spec; |
| 6353 | |
| 6354 | if (action == ALC_FIXUP_ACT_PROBE) |
| 6355 | snd_hda_jack_set_gating_jack(codec, spec->ext_mic_pin, |
| 6356 | spec->autocfg.hp_pins[0]); |
| 6357 | } |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6358 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6359 | enum { |
| 6360 | ALC269_FIXUP_SONY_VAIO, |
| 6361 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 6362 | ALC269_FIXUP_DELL_M101Z, |
| 6363 | ALC269_FIXUP_SKU_IGNORE, |
| 6364 | ALC269_FIXUP_ASUS_G73JW, |
| 6365 | ALC269_FIXUP_LENOVO_EAPD, |
| 6366 | ALC275_FIXUP_SONY_HWEQ, |
| 6367 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6368 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6369 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6370 | ALC269_FIXUP_QUANTA_MUTE, |
| 6371 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6372 | ALC269_FIXUP_AMIC, |
| 6373 | ALC269_FIXUP_DMIC, |
| 6374 | ALC269VB_FIXUP_AMIC, |
| 6375 | ALC269VB_FIXUP_DMIC, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6376 | ALC269_FIXUP_MIC1_MUTE_LED, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6377 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6378 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6379 | ALC269_FIXUP_LENOVO_DOCK, |
| 6380 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6381 | ALC271_FIXUP_AMIC_MIC2, |
| 6382 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6383 | }; |
| 6384 | |
| 6385 | static const struct alc_fixup alc269_fixups[] = { |
| 6386 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6387 | .type = ALC_FIXUP_VERBS, |
| 6388 | .v.verbs = (const struct hda_verb[]) { |
| 6389 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6390 | {} |
| 6391 | } |
| 6392 | }, |
| 6393 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6394 | .type = ALC_FIXUP_VERBS, |
| 6395 | .v.verbs = (const struct hda_verb[]) { |
| 6396 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6397 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6398 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6399 | { } |
| 6400 | }, |
| 6401 | .chained = true, |
| 6402 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6403 | }, |
| 6404 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6405 | .type = ALC_FIXUP_VERBS, |
| 6406 | .v.verbs = (const struct hda_verb[]) { |
| 6407 | /* Enables internal speaker */ |
| 6408 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6409 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6410 | {} |
| 6411 | } |
| 6412 | }, |
| 6413 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6414 | .type = ALC_FIXUP_FUNC, |
| 6415 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6416 | }, |
| 6417 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6418 | .type = ALC_FIXUP_PINS, |
| 6419 | .v.pins = (const struct alc_pincfg[]) { |
| 6420 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6421 | { } |
| 6422 | } |
| 6423 | }, |
| 6424 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6425 | .type = ALC_FIXUP_VERBS, |
| 6426 | .v.verbs = (const struct hda_verb[]) { |
| 6427 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6428 | {} |
| 6429 | } |
| 6430 | }, |
| 6431 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6432 | .type = ALC_FIXUP_FUNC, |
| 6433 | .v.func = alc269_fixup_hweq, |
| 6434 | .chained = true, |
| 6435 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6436 | }, |
| 6437 | [ALC271_FIXUP_DMIC] = { |
| 6438 | .type = ALC_FIXUP_FUNC, |
| 6439 | .v.func = alc271_fixup_dmic, |
| 6440 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6441 | [ALC269_FIXUP_PCM_44K] = { |
| 6442 | .type = ALC_FIXUP_FUNC, |
| 6443 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6444 | .chained = true, |
| 6445 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6446 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6447 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6448 | .type = ALC_FIXUP_FUNC, |
| 6449 | .v.func = alc269_fixup_stereo_dmic, |
| 6450 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6451 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6452 | .type = ALC_FIXUP_FUNC, |
| 6453 | .v.func = alc269_fixup_quanta_mute, |
| 6454 | }, |
| 6455 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6456 | .type = ALC_FIXUP_PINS, |
| 6457 | .v.pins = (const struct alc_pincfg[]) { |
| 6458 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6459 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6460 | { } |
| 6461 | }, |
| 6462 | .chained = true, |
| 6463 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6464 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6465 | [ALC269_FIXUP_AMIC] = { |
| 6466 | .type = ALC_FIXUP_PINS, |
| 6467 | .v.pins = (const struct alc_pincfg[]) { |
| 6468 | { 0x14, 0x99130110 }, /* speaker */ |
| 6469 | { 0x15, 0x0121401f }, /* HP out */ |
| 6470 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6471 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6472 | { } |
| 6473 | }, |
| 6474 | }, |
| 6475 | [ALC269_FIXUP_DMIC] = { |
| 6476 | .type = ALC_FIXUP_PINS, |
| 6477 | .v.pins = (const struct alc_pincfg[]) { |
| 6478 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6479 | { 0x14, 0x99130110 }, /* speaker */ |
| 6480 | { 0x15, 0x0121401f }, /* HP out */ |
| 6481 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6482 | { } |
| 6483 | }, |
| 6484 | }, |
| 6485 | [ALC269VB_FIXUP_AMIC] = { |
| 6486 | .type = ALC_FIXUP_PINS, |
| 6487 | .v.pins = (const struct alc_pincfg[]) { |
| 6488 | { 0x14, 0x99130110 }, /* speaker */ |
| 6489 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6490 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6491 | { 0x21, 0x0121401f }, /* HP out */ |
| 6492 | { } |
| 6493 | }, |
| 6494 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6495 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6496 | .type = ALC_FIXUP_PINS, |
| 6497 | .v.pins = (const struct alc_pincfg[]) { |
| 6498 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6499 | { 0x14, 0x99130110 }, /* speaker */ |
| 6500 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6501 | { 0x21, 0x0121401f }, /* HP out */ |
| 6502 | { } |
| 6503 | }, |
| 6504 | }, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6505 | [ALC269_FIXUP_MIC1_MUTE_LED] = { |
| 6506 | .type = ALC_FIXUP_FUNC, |
| 6507 | .v.func = alc269_fixup_mic1_mute, |
| 6508 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6509 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6510 | .type = ALC_FIXUP_FUNC, |
| 6511 | .v.func = alc269_fixup_mic2_mute, |
| 6512 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6513 | [ALC269_FIXUP_INV_DMIC] = { |
| 6514 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6515 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6516 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6517 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6518 | .type = ALC_FIXUP_PINS, |
| 6519 | .v.pins = (const struct alc_pincfg[]) { |
| 6520 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6521 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6522 | { } |
| 6523 | }, |
| 6524 | .chained = true, |
| 6525 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6526 | }, |
| 6527 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6528 | .type = ALC_FIXUP_FUNC, |
| 6529 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6530 | }, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6531 | [ALC271_FIXUP_AMIC_MIC2] = { |
| 6532 | .type = ALC_FIXUP_PINS, |
| 6533 | .v.pins = (const struct alc_pincfg[]) { |
| 6534 | { 0x14, 0x99130110 }, /* speaker */ |
| 6535 | { 0x19, 0x01a19c20 }, /* mic */ |
| 6536 | { 0x1b, 0x99a7012f }, /* int-mic */ |
| 6537 | { 0x21, 0x0121401f }, /* HP out */ |
| 6538 | { } |
| 6539 | }, |
| 6540 | }, |
| 6541 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { |
| 6542 | .type = ALC_FIXUP_FUNC, |
| 6543 | .v.func = alc271_hp_gate_mic_jack, |
| 6544 | .chained = true, |
| 6545 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
| 6546 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6547 | }; |
| 6548 | |
| 6549 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6550 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6551 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6552 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6553 | 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] | 6554 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6555 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6556 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6557 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6558 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6559 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6560 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6561 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6562 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6563 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6564 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6565 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6566 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6567 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6568 | 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] | 6569 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6570 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6571 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6572 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6573 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6574 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6575 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6576 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6577 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Stefán Freyr | 84f98fd | 2012-10-19 22:46:00 +0200 | [diff] [blame] | 6578 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6579 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6580 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6581 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6582 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6583 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6584 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6585 | /* Below is a quirk table taken from the old code. |
| 6586 | * Basically the device should work as is without the fixup table. |
| 6587 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6588 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6589 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6590 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6591 | ALC269_FIXUP_AMIC), |
| 6592 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6593 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6594 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6595 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6596 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6597 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6598 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6599 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6600 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6601 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6602 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6603 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6604 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6605 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6606 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6607 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6608 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6609 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6610 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6611 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6612 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6613 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6614 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6615 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6616 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6617 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6618 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6619 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6620 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6621 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6622 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6623 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6624 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6625 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6626 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6627 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6628 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6629 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6630 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6631 | #endif |
| 6632 | {} |
| 6633 | }; |
| 6634 | |
| 6635 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6636 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6637 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6638 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6639 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6640 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6641 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6642 | {} |
| 6643 | }; |
| 6644 | |
| 6645 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6646 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6647 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6648 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6649 | int val; |
| 6650 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6651 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6652 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6653 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6654 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6655 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6656 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6657 | } |
| 6658 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6659 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6660 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6661 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6662 | } |
| 6663 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6664 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6665 | val = alc_read_coef_idx(codec, 0x04); |
| 6666 | /* Power up output pin */ |
| 6667 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6668 | } |
| 6669 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6670 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6671 | val = alc_read_coef_idx(codec, 0xd); |
| 6672 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6673 | /* Capless ramp up clock control */ |
| 6674 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6675 | } |
| 6676 | val = alc_read_coef_idx(codec, 0x17); |
| 6677 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6678 | /* Class D power on reset */ |
| 6679 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6680 | } |
| 6681 | } |
| 6682 | |
| 6683 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6684 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6685 | |
| 6686 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6687 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6688 | } |
| 6689 | |
| 6690 | /* |
| 6691 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6692 | static int patch_alc269(struct hda_codec *codec) |
| 6693 | { |
| 6694 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6695 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6696 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6697 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6698 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6699 | return err; |
| 6700 | |
| 6701 | spec = codec->spec; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6702 | |
Herton Ronaldo Krzesinski | 9f720bb9 | 2012-09-27 10:38:14 -0300 | [diff] [blame] | 6703 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6704 | alc269_fixup_tbl, alc269_fixups); |
| 6705 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6706 | |
| 6707 | alc_auto_parse_customize_define(codec); |
| 6708 | |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6709 | switch (codec->vendor_id) { |
| 6710 | case 0x10ec0269: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6711 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6712 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6713 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6714 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6715 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6716 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6717 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6718 | break; |
| 6719 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6720 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6721 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6722 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6723 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6724 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6725 | case 0x0030: |
| 6726 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6727 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6728 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6729 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6730 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6731 | if (err < 0) |
| 6732 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6733 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6734 | alc269_fill_coef(codec); |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6735 | break; |
| 6736 | |
| 6737 | case 0x10ec0280: |
| 6738 | case 0x10ec0290: |
| 6739 | spec->codec_variant = ALC269_TYPE_ALC280; |
| 6740 | break; |
| 6741 | case 0x10ec0282: |
| 6742 | case 0x10ec0283: |
| 6743 | spec->codec_variant = ALC269_TYPE_ALC282; |
| 6744 | break; |
| 6745 | case 0x10ec0284: |
| 6746 | case 0x10ec0292: |
| 6747 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 6748 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6749 | } |
| 6750 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6751 | /* automatic parse from the BIOS config */ |
| 6752 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6753 | if (err < 0) |
| 6754 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6755 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6756 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6757 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6758 | if (err < 0) |
| 6759 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6760 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6761 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6762 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6763 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6764 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6765 | codec->patch_ops.resume = alc269_resume; |
| 6766 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6767 | spec->shutup = alc269_shutup; |
| 6768 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6769 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6770 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6771 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6772 | |
| 6773 | error: |
| 6774 | alc_free(codec); |
| 6775 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6776 | } |
| 6777 | |
| 6778 | /* |
| 6779 | * ALC861 |
| 6780 | */ |
| 6781 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6782 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6783 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6784 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6785 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6786 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6787 | } |
| 6788 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6789 | /* Pin config fixes */ |
| 6790 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6791 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6792 | ALC861_FIXUP_AMP_VREF_0F, |
| 6793 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6794 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6795 | }; |
| 6796 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6797 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6798 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6799 | const struct alc_fixup *fix, int action) |
| 6800 | { |
| 6801 | struct alc_spec *spec = codec->spec; |
| 6802 | unsigned int val; |
| 6803 | |
| 6804 | if (action != ALC_FIXUP_ACT_INIT) |
| 6805 | return; |
| 6806 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6807 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6808 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6809 | val |= AC_PINCTL_IN_EN; |
| 6810 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6811 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6812 | spec->keep_vref_in_automute = 1; |
| 6813 | } |
| 6814 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6815 | /* suppress the jack-detection */ |
| 6816 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6817 | const struct alc_fixup *fix, int action) |
| 6818 | { |
| 6819 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6820 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6821 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6822 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6823 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6824 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6825 | .type = ALC_FIXUP_PINS, |
| 6826 | .v.pins = (const struct alc_pincfg[]) { |
| 6827 | { 0x0b, 0x0221101f }, /* HP */ |
| 6828 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6829 | { } |
| 6830 | } |
| 6831 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6832 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6833 | .type = ALC_FIXUP_FUNC, |
| 6834 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6835 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6836 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6837 | .type = ALC_FIXUP_FUNC, |
| 6838 | .v.func = alc_fixup_no_jack_detect, |
| 6839 | }, |
| 6840 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6841 | .type = ALC_FIXUP_FUNC, |
| 6842 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6843 | .chained = true, |
| 6844 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6845 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6846 | }; |
| 6847 | |
| 6848 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6849 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6850 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6851 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6852 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6853 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6854 | 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] | 6855 | {} |
| 6856 | }; |
| 6857 | |
| 6858 | /* |
| 6859 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6860 | static int patch_alc861(struct hda_codec *codec) |
| 6861 | { |
| 6862 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6863 | int err; |
| 6864 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6865 | err = alc_alloc_spec(codec, 0x15); |
| 6866 | if (err < 0) |
| 6867 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6868 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6869 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6870 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6871 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6872 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6873 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6874 | /* automatic parse from the BIOS config */ |
| 6875 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6876 | if (err < 0) |
| 6877 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6878 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6879 | if (!spec->no_analog) { |
| 6880 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6881 | if (err < 0) |
| 6882 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6883 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6884 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6885 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6886 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6887 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6888 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6889 | #endif |
| 6890 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6891 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6892 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6893 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6894 | |
| 6895 | error: |
| 6896 | alc_free(codec); |
| 6897 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6898 | } |
| 6899 | |
| 6900 | /* |
| 6901 | * ALC861-VD support |
| 6902 | * |
| 6903 | * Based on ALC882 |
| 6904 | * |
| 6905 | * In addition, an independent DAC |
| 6906 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6907 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6908 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6909 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6910 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6911 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6912 | } |
| 6913 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6914 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6915 | ALC660VD_FIX_ASUS_GPIO1, |
| 6916 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6917 | }; |
| 6918 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6919 | /* exclude VREF80 */ |
| 6920 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6921 | const struct alc_fixup *fix, int action) |
| 6922 | { |
| 6923 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | b78562b | 2012-12-17 20:06:49 +0100 | [diff] [blame] | 6924 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
| 6925 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6926 | } |
| 6927 | } |
| 6928 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6929 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6930 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6931 | .type = ALC_FIXUP_VERBS, |
| 6932 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6933 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6934 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6935 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6936 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6937 | { } |
| 6938 | } |
| 6939 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6940 | [ALC861VD_FIX_DALLAS] = { |
| 6941 | .type = ALC_FIXUP_FUNC, |
| 6942 | .v.func = alc861vd_fixup_dallas, |
| 6943 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6944 | }; |
| 6945 | |
| 6946 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6947 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6948 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6949 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6950 | {} |
| 6951 | }; |
| 6952 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6953 | /* |
| 6954 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6955 | static int patch_alc861vd(struct hda_codec *codec) |
| 6956 | { |
| 6957 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6958 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6959 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6960 | err = alc_alloc_spec(codec, 0x0b); |
| 6961 | if (err < 0) |
| 6962 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6963 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6964 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6965 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6966 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6967 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6968 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6969 | /* automatic parse from the BIOS config */ |
| 6970 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6971 | if (err < 0) |
| 6972 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6973 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6974 | if (!spec->no_analog) { |
| 6975 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6976 | if (err < 0) |
| 6977 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6978 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6979 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6980 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6981 | codec->patch_ops = alc_patch_ops; |
| 6982 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6983 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6984 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6985 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6986 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6987 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6988 | |
| 6989 | error: |
| 6990 | alc_free(codec); |
| 6991 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6992 | } |
| 6993 | |
| 6994 | /* |
| 6995 | * ALC662 support |
| 6996 | * |
| 6997 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6998 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6999 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 7000 | * 6-channel independent captures. |
| 7001 | * |
| 7002 | * In addition, an independent DAC for the multi-playback (not used in this |
| 7003 | * driver yet). |
| 7004 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7005 | |
| 7006 | /* |
| 7007 | * BIOS auto configuration |
| 7008 | */ |
| 7009 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7010 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 7011 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7012 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7013 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 7014 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 7015 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 7016 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7017 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 7018 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7019 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7020 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7021 | ssids = alc662_ssids; |
| 7022 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7023 | } |
| 7024 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7025 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7026 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 7027 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7028 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 7029 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7030 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 7031 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 7032 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 7033 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 7034 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 7035 | printk(KERN_WARNING |
| 7036 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 7037 | } |
| 7038 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7039 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7040 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7041 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7042 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7043 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7044 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7045 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7046 | ALC662_FIXUP_ASUS_MODE1, |
| 7047 | ALC662_FIXUP_ASUS_MODE2, |
| 7048 | ALC662_FIXUP_ASUS_MODE3, |
| 7049 | ALC662_FIXUP_ASUS_MODE4, |
| 7050 | ALC662_FIXUP_ASUS_MODE5, |
| 7051 | ALC662_FIXUP_ASUS_MODE6, |
| 7052 | ALC662_FIXUP_ASUS_MODE7, |
| 7053 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7054 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7055 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7056 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7057 | }; |
| 7058 | |
| 7059 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7060 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7061 | .type = ALC_FIXUP_PINS, |
| 7062 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7063 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 7064 | { } |
| 7065 | } |
| 7066 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7067 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7068 | .type = ALC_FIXUP_PINS, |
| 7069 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7070 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 7071 | { } |
| 7072 | } |
| 7073 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7074 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7075 | .type = ALC_FIXUP_FUNC, |
| 7076 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7077 | }, |
| 7078 | [ALC662_FIXUP_CZC_P10T] = { |
| 7079 | .type = ALC_FIXUP_VERBS, |
| 7080 | .v.verbs = (const struct hda_verb[]) { |
| 7081 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 7082 | {} |
| 7083 | } |
| 7084 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7085 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 7086 | .type = ALC_FIXUP_FUNC, |
| 7087 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 7088 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7089 | [ALC662_FIXUP_HP_RP5800] = { |
| 7090 | .type = ALC_FIXUP_PINS, |
| 7091 | .v.pins = (const struct alc_pincfg[]) { |
| 7092 | { 0x14, 0x0221201f }, /* HP out */ |
| 7093 | { } |
| 7094 | }, |
| 7095 | .chained = true, |
| 7096 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7097 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7098 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 7099 | .type = ALC_FIXUP_PINS, |
| 7100 | .v.pins = (const struct alc_pincfg[]) { |
| 7101 | { 0x14, 0x99130110 }, /* speaker */ |
| 7102 | { 0x18, 0x01a19c20 }, /* mic */ |
| 7103 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 7104 | { 0x21, 0x0121401f }, /* HP out */ |
| 7105 | { } |
| 7106 | }, |
| 7107 | .chained = true, |
| 7108 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7109 | }, |
| 7110 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7111 | .type = ALC_FIXUP_PINS, |
| 7112 | .v.pins = (const struct alc_pincfg[]) { |
| 7113 | { 0x14, 0x99130110 }, /* speaker */ |
| 7114 | { 0x18, 0x01a19820 }, /* mic */ |
| 7115 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 7116 | { 0x1b, 0x0121401f }, /* HP out */ |
| 7117 | { } |
| 7118 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7119 | .chained = true, |
| 7120 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7121 | }, |
| 7122 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 7123 | .type = ALC_FIXUP_PINS, |
| 7124 | .v.pins = (const struct alc_pincfg[]) { |
| 7125 | { 0x14, 0x99130110 }, /* speaker */ |
| 7126 | { 0x15, 0x0121441f }, /* HP */ |
| 7127 | { 0x18, 0x01a19840 }, /* mic */ |
| 7128 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7129 | { 0x21, 0x01211420 }, /* HP2 */ |
| 7130 | { } |
| 7131 | }, |
| 7132 | .chained = true, |
| 7133 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7134 | }, |
| 7135 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 7136 | .type = ALC_FIXUP_PINS, |
| 7137 | .v.pins = (const struct alc_pincfg[]) { |
| 7138 | { 0x14, 0x99130110 }, /* speaker */ |
| 7139 | { 0x16, 0x99130111 }, /* speaker */ |
| 7140 | { 0x18, 0x01a19840 }, /* mic */ |
| 7141 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7142 | { 0x21, 0x0121441f }, /* HP */ |
| 7143 | { } |
| 7144 | }, |
| 7145 | .chained = true, |
| 7146 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7147 | }, |
| 7148 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 7149 | .type = ALC_FIXUP_PINS, |
| 7150 | .v.pins = (const struct alc_pincfg[]) { |
| 7151 | { 0x14, 0x99130110 }, /* speaker */ |
| 7152 | { 0x15, 0x0121441f }, /* HP */ |
| 7153 | { 0x16, 0x99130111 }, /* speaker */ |
| 7154 | { 0x18, 0x01a19840 }, /* mic */ |
| 7155 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7156 | { } |
| 7157 | }, |
| 7158 | .chained = true, |
| 7159 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7160 | }, |
| 7161 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 7162 | .type = ALC_FIXUP_PINS, |
| 7163 | .v.pins = (const struct alc_pincfg[]) { |
| 7164 | { 0x14, 0x99130110 }, /* speaker */ |
| 7165 | { 0x15, 0x01211420 }, /* HP2 */ |
| 7166 | { 0x18, 0x01a19840 }, /* mic */ |
| 7167 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7168 | { 0x1b, 0x0121441f }, /* HP */ |
| 7169 | { } |
| 7170 | }, |
| 7171 | .chained = true, |
| 7172 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7173 | }, |
| 7174 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 7175 | .type = ALC_FIXUP_PINS, |
| 7176 | .v.pins = (const struct alc_pincfg[]) { |
| 7177 | { 0x14, 0x99130110 }, /* speaker */ |
| 7178 | { 0x17, 0x99130111 }, /* speaker */ |
| 7179 | { 0x18, 0x01a19840 }, /* mic */ |
| 7180 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7181 | { 0x1b, 0x01214020 }, /* HP */ |
| 7182 | { 0x21, 0x0121401f }, /* HP */ |
| 7183 | { } |
| 7184 | }, |
| 7185 | .chained = true, |
| 7186 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7187 | }, |
| 7188 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 7189 | .type = ALC_FIXUP_PINS, |
| 7190 | .v.pins = (const struct alc_pincfg[]) { |
| 7191 | { 0x14, 0x99130110 }, /* speaker */ |
| 7192 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 7193 | { 0x15, 0x01214020 }, /* HP */ |
| 7194 | { 0x17, 0x99130111 }, /* speaker */ |
| 7195 | { 0x18, 0x01a19840 }, /* mic */ |
| 7196 | { 0x21, 0x0121401f }, /* HP */ |
| 7197 | { } |
| 7198 | }, |
| 7199 | .chained = true, |
| 7200 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7201 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7202 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 7203 | .type = ALC_FIXUP_FUNC, |
| 7204 | .v.func = alc_fixup_no_jack_detect, |
| 7205 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7206 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 7207 | .type = ALC_FIXUP_PINS, |
| 7208 | .v.pins = (const struct alc_pincfg[]) { |
| 7209 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 7210 | { } |
| 7211 | } |
| 7212 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7213 | [ALC662_FIXUP_INV_DMIC] = { |
| 7214 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7215 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7216 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7217 | }; |
| 7218 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7219 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7220 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 7221 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7222 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7223 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7224 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7225 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7226 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7227 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 7228 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 7229 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7230 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7231 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7232 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7233 | |
| 7234 | #if 0 |
| 7235 | /* Below is a quirk table taken from the old code. |
| 7236 | * Basically the device should work as is without the fixup table. |
| 7237 | * If BIOS doesn't give a proper info, enable the corresponding |
| 7238 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 7239 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7240 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 7241 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 7242 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 7243 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 7244 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7245 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7246 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7247 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 7248 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 7249 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7250 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 7251 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 7252 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 7253 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 7254 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 7255 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7256 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 7257 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 7258 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7259 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7260 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7261 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7262 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 7263 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 7264 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 7265 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7266 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 7267 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7268 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7269 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 7270 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7271 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7272 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 7273 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 7274 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 7275 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 7276 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 7277 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 7278 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 7279 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7280 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 7281 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 7282 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7283 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 7284 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 7285 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 7286 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 7287 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 7288 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7289 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 7290 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7291 | {} |
| 7292 | }; |
| 7293 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7294 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 7295 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7296 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 7297 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 7298 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 7299 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 7300 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 7301 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 7302 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 7303 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7304 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7305 | {} |
| 7306 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7307 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7308 | static void alc662_fill_coef(struct hda_codec *codec) |
| 7309 | { |
| 7310 | int val, coef; |
| 7311 | |
| 7312 | coef = alc_get_coef0(codec); |
| 7313 | |
| 7314 | switch (codec->vendor_id) { |
| 7315 | case 0x10ec0662: |
| 7316 | if ((coef & 0x00f0) == 0x0030) { |
| 7317 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 7318 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 7319 | } |
| 7320 | break; |
| 7321 | case 0x10ec0272: |
| 7322 | case 0x10ec0273: |
| 7323 | case 0x10ec0663: |
| 7324 | case 0x10ec0665: |
| 7325 | case 0x10ec0670: |
| 7326 | case 0x10ec0671: |
| 7327 | case 0x10ec0672: |
| 7328 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 7329 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 7330 | break; |
| 7331 | } |
| 7332 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7333 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7334 | /* |
| 7335 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7336 | static int patch_alc662(struct hda_codec *codec) |
| 7337 | { |
| 7338 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7339 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7340 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7341 | err = alc_alloc_spec(codec, 0x0b); |
| 7342 | if (err < 0) |
| 7343 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7344 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7345 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7346 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7347 | /* handle multiple HPs as is */ |
| 7348 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 7349 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 7350 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 7351 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7352 | spec->init_hook = alc662_fill_coef; |
| 7353 | alc662_fill_coef(codec); |
| 7354 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 7355 | alc_pick_fixup(codec, alc662_fixup_models, |
| 7356 | alc662_fixup_tbl, alc662_fixups); |
| 7357 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 7358 | |
| 7359 | alc_auto_parse_customize_define(codec); |
| 7360 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 7361 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7362 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 7363 | spec->cdefine.platform_type == 1) { |
| 7364 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 7365 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 7366 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7367 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 7368 | /* automatic parse from the BIOS config */ |
| 7369 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7370 | if (err < 0) |
| 7371 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7372 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7373 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 7374 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7375 | if (err < 0) |
| 7376 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 7377 | switch (codec->vendor_id) { |
| 7378 | case 0x10ec0662: |
| 7379 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 7380 | break; |
| 7381 | case 0x10ec0272: |
| 7382 | case 0x10ec0663: |
| 7383 | case 0x10ec0665: |
| 7384 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 7385 | break; |
| 7386 | case 0x10ec0273: |
| 7387 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 7388 | break; |
| 7389 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7390 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 7391 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7392 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 7393 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7394 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 7395 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 7396 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7397 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7398 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7399 | error: |
| 7400 | alc_free(codec); |
| 7401 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 7402 | } |
| 7403 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7404 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7405 | * ALC680 support |
| 7406 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7407 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7408 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7409 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7410 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7411 | } |
| 7412 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7413 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7414 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7415 | static int patch_alc680(struct hda_codec *codec) |
| 7416 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7417 | int err; |
| 7418 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7419 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7420 | err = alc_alloc_spec(codec, 0); |
| 7421 | if (err < 0) |
| 7422 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7423 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7424 | /* automatic parse from the BIOS config */ |
| 7425 | err = alc680_parse_auto_config(codec); |
| 7426 | if (err < 0) { |
| 7427 | alc_free(codec); |
| 7428 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7429 | } |
| 7430 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7431 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7432 | |
| 7433 | return 0; |
| 7434 | } |
| 7435 | |
| 7436 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7437 | * patch entries |
| 7438 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7439 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7440 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7441 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7442 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7443 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7444 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7445 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7446 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7447 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7448 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7449 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7450 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7451 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7452 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 7453 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7454 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
David Henningsson | af02dde | 2012-11-21 08:57:58 +0100 | [diff] [blame] | 7455 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7456 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7457 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7458 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7459 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7460 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7461 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7462 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7463 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7464 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7465 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7466 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7467 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7468 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7469 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7470 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7471 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7472 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7473 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7474 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7475 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7476 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7477 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7478 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7479 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7480 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7481 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7482 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7483 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7484 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7485 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7486 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7487 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7488 | {} /* terminator */ |
| 7489 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7490 | |
| 7491 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7492 | |
| 7493 | MODULE_LICENSE("GPL"); |
| 7494 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7495 | |
| 7496 | static struct hda_codec_preset_list realtek_list = { |
| 7497 | .preset = snd_hda_preset_realtek, |
| 7498 | .owner = THIS_MODULE, |
| 7499 | }; |
| 7500 | |
| 7501 | static int __init patch_realtek_init(void) |
| 7502 | { |
| 7503 | return snd_hda_add_codec_preset(&realtek_list); |
| 7504 | } |
| 7505 | |
| 7506 | static void __exit patch_realtek_exit(void) |
| 7507 | { |
| 7508 | snd_hda_delete_codec_preset(&realtek_list); |
| 7509 | } |
| 7510 | |
| 7511 | module_init(patch_realtek_init) |
| 7512 | module_exit(patch_realtek_exit) |