Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4 | * HD audio interface patch for Realtek ALC codecs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 409a3e9 | 2012-03-27 13:01:01 +1030 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@just42.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 32 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 35 | #include "hda_auto_parser.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 36 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 37 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 39 | /* unsol event tags */ |
| 40 | #define ALC_FRONT_EVENT 0x01 |
| 41 | #define ALC_DCVOL_EVENT 0x02 |
| 42 | #define ALC_HP_EVENT 0x04 |
| 43 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 44 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 45 | /* for GPIO Poll */ |
| 46 | #define GPIO_MASK 0x03 |
| 47 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 48 | /* extra amp-initialization sequence types */ |
| 49 | enum { |
| 50 | ALC_INIT_NONE, |
| 51 | ALC_INIT_DEFAULT, |
| 52 | ALC_INIT_GPIO1, |
| 53 | ALC_INIT_GPIO2, |
| 54 | ALC_INIT_GPIO3, |
| 55 | }; |
| 56 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 57 | struct alc_customize_define { |
| 58 | unsigned int sku_cfg; |
| 59 | unsigned char port_connectivity; |
| 60 | unsigned char check_sum; |
| 61 | unsigned char customization; |
| 62 | unsigned char external_amp; |
| 63 | unsigned int enable_pcbeep:1; |
| 64 | unsigned int platform_type:1; |
| 65 | unsigned int swap:1; |
| 66 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 67 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 70 | struct alc_multi_io { |
| 71 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 72 | hda_nid_t dac; /* DAC to be connected */ |
| 73 | unsigned int ctl_in; /* cached input-pin control value */ |
| 74 | }; |
| 75 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 76 | /* make compatible with old code */ |
| 77 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 78 | #define alc_apply_fixup snd_hda_apply_fixup |
| 79 | #define alc_pick_fixup snd_hda_pick_fixup |
| 80 | #define alc_fixup hda_fixup |
| 81 | #define alc_pincfg hda_pintbl |
| 82 | #define alc_model_fixup hda_model_fixup |
| 83 | |
| 84 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 85 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 86 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 87 | |
| 88 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 89 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 90 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 91 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 92 | |
| 93 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 94 | #define MAX_NID_PATH_DEPTH 5 |
| 95 | |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 96 | enum { |
| 97 | NID_PATH_VOL_CTL, |
| 98 | NID_PATH_MUTE_CTL, |
| 99 | NID_PATH_BOOST_CTL, |
| 100 | NID_PATH_NUM_CTLS |
| 101 | }; |
| 102 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 103 | /* Widget connection path |
| 104 | * |
| 105 | * For output, stored in the order of DAC -> ... -> pin, |
| 106 | * for input, pin -> ... -> ADC. |
| 107 | * |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 108 | * idx[i] contains the source index number to select on of the widget path[i]; |
| 109 | * 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] | 110 | * multi[] indicates whether it's a selector widget with multi-connectors |
| 111 | * (i.e. the connection selection is mandatory) |
| 112 | * vol_ctl and mute_ctl contains the NIDs for the assigned mixers |
| 113 | */ |
| 114 | struct nid_path { |
| 115 | int depth; |
| 116 | hda_nid_t path[MAX_NID_PATH_DEPTH]; |
| 117 | unsigned char idx[MAX_NID_PATH_DEPTH]; |
| 118 | unsigned char multi[MAX_NID_PATH_DEPTH]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 119 | unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */ |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 120 | bool active; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 121 | }; |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | struct alc_spec { |
| 124 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 125 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | unsigned int num_mixers; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 127 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 129 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 130 | const struct hda_pcm_stream *stream_analog_playback; |
| 131 | const struct hda_pcm_stream *stream_analog_capture; |
| 132 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 133 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 135 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 136 | const struct hda_pcm_stream *stream_digital_playback; |
| 137 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 140 | struct hda_multi_out multiout; /* playback set-up |
| 141 | * max_channels, dacs must be set |
| 142 | * dig_out_nid and hp_nid are optional |
| 143 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 144 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 145 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 146 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | /* capture */ |
| 149 | unsigned int num_adc_nids; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 150 | hda_nid_t adc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 151 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 152 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 154 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 155 | hda_nid_t cur_adc; |
| 156 | unsigned int cur_adc_stream_tag; |
| 157 | unsigned int cur_adc_format; |
| 158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | /* capture source */ |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 160 | struct hda_input_mux input_mux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 162 | hda_nid_t ext_mic_pin; |
| 163 | hda_nid_t dock_mic_pin; |
| 164 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
| 166 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 167 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | int num_channel_mode; |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 169 | int const_channel_count; /* min. channel count (for speakers) */ |
| 170 | int ext_channel_count; /* current channel count for multi-io */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 173 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 174 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 175 | /* dynamic controls, init_verbs and input_mux */ |
| 176 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 177 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 178 | struct snd_array kctls; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 179 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 180 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 181 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 182 | 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] | 183 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 184 | hda_nid_t shared_mic_vref_pin; |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 185 | int inv_dmic_split_idx; /* used internally for inv_dmic_split */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 186 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 187 | /* DAC list */ |
| 188 | int num_all_dacs; |
| 189 | hda_nid_t all_dacs[16]; |
| 190 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 191 | /* path list */ |
| 192 | struct snd_array paths; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 193 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 194 | /* hooks */ |
| 195 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 196 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 197 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 198 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 199 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 200 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 201 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 202 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 203 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 204 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 205 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 206 | unsigned int auto_mic:1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 207 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 208 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 209 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 210 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 211 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 212 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 213 | 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] | 214 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 215 | /* other flags */ |
Takashi Iwai | 20c18f5 | 2012-12-18 14:33:21 +0100 | [diff] [blame] | 216 | unsigned int need_dac_fix:1; /* need to limit DACs for multi channels */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 217 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 218 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 219 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 220 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 221 | 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] | 222 | unsigned int no_primary_hp:1; /* Don't prefer HP pins to speaker pins */ |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 223 | unsigned int multi_cap_vol:1; /* allow multiple capture xxx volumes */ |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 224 | unsigned int inv_dmic_split:1; /* inverted dmic w/a for conexant */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 225 | |
Takashi Iwai | 20c18f5 | 2012-12-18 14:33:21 +0100 | [diff] [blame] | 226 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 227 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 228 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 229 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 230 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 231 | /* for virtual master */ |
| 232 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 233 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 234 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 235 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 236 | int num_loopbacks; |
| 237 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 238 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 239 | |
| 240 | /* for PLL fix */ |
| 241 | hda_nid_t pll_nid; |
| 242 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 243 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 244 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 245 | /* multi-io */ |
| 246 | int multi_ios; |
| 247 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 248 | |
| 249 | /* bind volumes */ |
| 250 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 251 | }; |
| 252 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 253 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 254 | int dir, unsigned int bits) |
| 255 | { |
| 256 | if (!nid) |
| 257 | return false; |
| 258 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 259 | if (query_amp_caps(codec, nid, dir) & bits) |
| 260 | return true; |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | #define nid_has_mute(codec, nid, dir) \ |
| 265 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 266 | #define nid_has_volume(codec, nid, dir) \ |
| 267 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 268 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 269 | static struct nid_path * |
| 270 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid); |
| 271 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 272 | bool enable, bool add_aamix); |
| 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | /* |
| 275 | * input MUX handling |
| 276 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 277 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 278 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | { |
| 280 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 281 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 282 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 285 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 286 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | { |
| 288 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 289 | struct alc_spec *spec = codec->spec; |
| 290 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 291 | |
| 292 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 293 | return 0; |
| 294 | } |
| 295 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 296 | static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx) |
| 297 | { |
| 298 | struct alc_spec *spec = codec->spec; |
| 299 | if (spec->dyn_adc_switch) |
| 300 | adc_idx = spec->dyn_adc_idx[imux_idx]; |
| 301 | return spec->adc_nids[adc_idx]; |
| 302 | } |
| 303 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 304 | 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] | 305 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 306 | struct alc_spec *spec = codec->spec; |
| 307 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 308 | |
| 309 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 310 | /* stream is running, let's swap the current ADC */ |
| 311 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 312 | spec->cur_adc = new_adc; |
| 313 | snd_hda_codec_setup_stream(codec, new_adc, |
| 314 | spec->cur_adc_stream_tag, 0, |
| 315 | spec->cur_adc_format); |
| 316 | return true; |
| 317 | } |
| 318 | return false; |
| 319 | } |
| 320 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 321 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 322 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 323 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 324 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 325 | /* for shared I/O, change the pin-control accordingly */ |
| 326 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 327 | { |
| 328 | struct alc_spec *spec = codec->spec; |
| 329 | unsigned int val; |
| 330 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 331 | /* NOTE: this assumes that there are only two inputs, the |
| 332 | * first is the real internal mic and the second is HP/mic jack. |
| 333 | */ |
| 334 | |
| 335 | val = snd_hda_get_default_vref(codec, pin); |
| 336 | |
| 337 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 338 | instead, as suggested by Realtek */ |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 339 | if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { |
| 340 | const hda_nid_t vref_pin = spec->shared_mic_vref_pin; |
| 341 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 342 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 343 | snd_hda_set_pin_ctl(codec, vref_pin, PIN_IN | (set_as_mic ? vref_val : 0)); |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 347 | snd_hda_set_pin_ctl(codec, pin, val); |
| 348 | |
| 349 | spec->automute_speaker = !set_as_mic; |
| 350 | call_update_outputs(codec); |
| 351 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 352 | |
| 353 | /* select the given imux item; either unmute exclusively or select the route */ |
| 354 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 355 | unsigned int idx, bool force) |
| 356 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 358 | const struct hda_input_mux *imux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 359 | struct nid_path *path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 361 | imux = &spec->input_mux; |
| 362 | if (!imux->num_items) |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 363 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 364 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 365 | if (idx >= imux->num_items) |
| 366 | idx = imux->num_items - 1; |
| 367 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 368 | return 0; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 369 | |
| 370 | path = get_nid_path(codec, spec->imux_pins[spec->cur_mux[adc_idx]], |
| 371 | spec->adc_nids[adc_idx]); |
| 372 | if (!path) |
| 373 | return 0; |
| 374 | if (path->active) |
| 375 | activate_path(codec, path, false, false); |
| 376 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 377 | spec->cur_mux[adc_idx] = idx; |
| 378 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 379 | if (spec->shared_mic_hp) |
| 380 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 381 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 382 | if (spec->dyn_adc_switch) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 383 | alc_dyn_adc_pcm_resetup(codec, idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 384 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 385 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 386 | get_adc_nid(codec, adc_idx, idx)); |
| 387 | if (!path) |
| 388 | return 0; |
| 389 | if (path->active) |
| 390 | return 0; |
| 391 | activate_path(codec, path, true, false); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 392 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 393 | return 1; |
| 394 | } |
| 395 | |
| 396 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 397 | struct snd_ctl_elem_value *ucontrol) |
| 398 | { |
| 399 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 400 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 401 | return alc_mux_select(codec, adc_idx, |
| 402 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 403 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 406 | * set up the input pin config (depending on the given auto-pin type) |
| 407 | */ |
| 408 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 409 | int auto_pin_type) |
| 410 | { |
| 411 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 412 | if (auto_pin_type == AUTO_PIN_MIC) |
| 413 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 414 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 418 | * Append the given mixer and verb elements for the later use |
| 419 | * The mixer array is referred in build_controls(), and init_verbs are |
| 420 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 421 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 422 | 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] | 423 | { |
| 424 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 425 | return; |
| 426 | spec->mixers[spec->num_mixers++] = mix; |
| 427 | } |
| 428 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 429 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 430 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 431 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 432 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 433 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 434 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 435 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 436 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 437 | { } |
| 438 | }; |
| 439 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 440 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 441 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 442 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 443 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 444 | { } |
| 445 | }; |
| 446 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 447 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 448 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 449 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 450 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 451 | { } |
| 452 | }; |
| 453 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 454 | /* |
| 455 | * Fix hardware PLL issue |
| 456 | * On some codecs, the analog PLL gating control must be off while |
| 457 | * the default value is 1. |
| 458 | */ |
| 459 | static void alc_fix_pll(struct hda_codec *codec) |
| 460 | { |
| 461 | struct alc_spec *spec = codec->spec; |
| 462 | unsigned int val; |
| 463 | |
| 464 | if (!spec->pll_nid) |
| 465 | return; |
| 466 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 467 | spec->pll_coef_idx); |
| 468 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 469 | AC_VERB_GET_PROC_COEF, 0); |
| 470 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 471 | spec->pll_coef_idx); |
| 472 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 473 | val & ~(1 << spec->pll_coef_bit)); |
| 474 | } |
| 475 | |
| 476 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 477 | unsigned int coef_idx, unsigned int coef_bit) |
| 478 | { |
| 479 | struct alc_spec *spec = codec->spec; |
| 480 | spec->pll_nid = nid; |
| 481 | spec->pll_coef_idx = coef_idx; |
| 482 | spec->pll_coef_bit = coef_bit; |
| 483 | alc_fix_pll(codec); |
| 484 | } |
| 485 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 486 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 487 | * Jack detections for HP auto-mute and mic-switch |
| 488 | */ |
| 489 | |
| 490 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 491 | 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] | 492 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 493 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 494 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 495 | for (i = 0; i < num_pins; i++) { |
| 496 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 497 | if (!nid) |
| 498 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 499 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 500 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | return present; |
| 502 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 503 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 504 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 505 | 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] | 506 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 507 | { |
| 508 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 509 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 510 | int i; |
| 511 | |
| 512 | for (i = 0; i < num_pins; i++) { |
| 513 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 514 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 515 | if (!nid) |
| 516 | break; |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 517 | /* don't reset VREF value in case it's controlling |
| 518 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 519 | */ |
| 520 | if (spec->keep_vref_in_automute) { |
| 521 | val = snd_hda_codec_read(codec, nid, 0, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 522 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 523 | val &= ~PIN_HP; |
| 524 | } else |
| 525 | val = 0; |
| 526 | val |= pin_bits; |
| 527 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 528 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 529 | } |
| 530 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 531 | /* Toggle outputs muting */ |
| 532 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 533 | { |
| 534 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 535 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 536 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 537 | /* Control HP pins/amps depending on master_mute state; |
| 538 | * in general, HP pins/amps control should be enabled in all cases, |
| 539 | * but currently set only for master_mute, just to be safe |
| 540 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 541 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 542 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 543 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 544 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 545 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 546 | on = 0; |
| 547 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 548 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 549 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 550 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 551 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 552 | |
| 553 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 554 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 555 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 556 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 557 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 558 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 559 | on = 0; |
| 560 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 561 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 562 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 563 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 564 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 565 | } |
| 566 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 567 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 568 | { |
| 569 | struct alc_spec *spec = codec->spec; |
| 570 | if (spec->automute_hook) |
| 571 | spec->automute_hook(codec); |
| 572 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 573 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 574 | } |
| 575 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 576 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 577 | 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] | 578 | { |
| 579 | struct alc_spec *spec = codec->spec; |
| 580 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 581 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 582 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 583 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 584 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 585 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 586 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 587 | } |
| 588 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 589 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 590 | 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] | 591 | { |
| 592 | struct alc_spec *spec = codec->spec; |
| 593 | |
David Henningsson | f7f4b232 | 2012-10-10 16:32:09 +0200 | [diff] [blame] | 594 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 595 | return; |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 596 | /* check LO jack only when it's different from HP */ |
| 597 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 598 | return; |
| 599 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 600 | spec->line_jack_present = |
| 601 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 602 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 603 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 604 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 605 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 606 | } |
| 607 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 608 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 609 | 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] | 610 | { |
| 611 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 612 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 613 | |
Takashi Iwai | 480967d | 2012-12-18 14:29:52 +0100 | [diff] [blame] | 614 | if (!spec->auto_mic) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 615 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 616 | 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] | 617 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 618 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 619 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 620 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 621 | else if (spec->dock_mic_idx >= 0 && |
| 622 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 623 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 624 | else |
| 625 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 626 | } |
| 627 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 628 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 629 | 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] | 630 | { |
| 631 | unsigned int val; |
| 632 | struct snd_kcontrol *kctl; |
| 633 | struct snd_ctl_elem_value *uctl; |
| 634 | |
| 635 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 636 | if (!kctl) |
| 637 | return; |
| 638 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 639 | if (!uctl) |
| 640 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 641 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 642 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 643 | val &= HDA_AMP_VOLMASK; |
| 644 | uctl->value.integer.value[0] = val; |
| 645 | uctl->value.integer.value[1] = val; |
| 646 | kctl->put(kctl, uctl); |
| 647 | kfree(uctl); |
| 648 | } |
| 649 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 650 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 651 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 652 | /* For some reason, the res given from ALC880 is broken. |
| 653 | Here we adjust it properly. */ |
| 654 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 655 | } |
| 656 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 657 | /* additional initialization for ALC888 variants */ |
| 658 | static void alc888_coef_init(struct hda_codec *codec) |
| 659 | { |
| 660 | unsigned int tmp; |
| 661 | |
| 662 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 663 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 664 | 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] | 665 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 666 | /* alc888S-VC */ |
| 667 | snd_hda_codec_read(codec, 0x20, 0, |
| 668 | AC_VERB_SET_PROC_COEF, 0x830); |
| 669 | else |
| 670 | /* alc888-VB */ |
| 671 | snd_hda_codec_read(codec, 0x20, 0, |
| 672 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 673 | } |
| 674 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 675 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 676 | static void alc889_coef_init(struct hda_codec *codec) |
| 677 | { |
| 678 | unsigned int tmp; |
| 679 | |
| 680 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 681 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 682 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 683 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 684 | } |
| 685 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 686 | /* turn on/off EAPD control (only if available) */ |
| 687 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 688 | { |
| 689 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 690 | return; |
| 691 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 692 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 693 | on ? 2 : 0); |
| 694 | } |
| 695 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 696 | /* turn on/off EAPD controls of the codec */ |
| 697 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 698 | { |
| 699 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 700 | static hda_nid_t pins[] = { |
| 701 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 702 | }; |
| 703 | hda_nid_t *p; |
| 704 | for (p = pins; *p; p++) |
| 705 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 706 | } |
| 707 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 708 | /* generic shutup callback; |
| 709 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 710 | */ |
| 711 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 712 | { |
| 713 | alc_auto_setup_eapd(codec, false); |
| 714 | msleep(200); |
| 715 | } |
| 716 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 717 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 718 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 719 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 720 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 721 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 722 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 723 | switch (type) { |
| 724 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 725 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 726 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 727 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 728 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 729 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 730 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 731 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 732 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 733 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 734 | switch (codec->vendor_id) { |
| 735 | case 0x10ec0260: |
| 736 | snd_hda_codec_write(codec, 0x1a, 0, |
| 737 | AC_VERB_SET_COEF_INDEX, 7); |
| 738 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 739 | AC_VERB_GET_PROC_COEF, 0); |
| 740 | snd_hda_codec_write(codec, 0x1a, 0, |
| 741 | AC_VERB_SET_COEF_INDEX, 7); |
| 742 | snd_hda_codec_write(codec, 0x1a, 0, |
| 743 | AC_VERB_SET_PROC_COEF, |
| 744 | tmp | 0x2010); |
| 745 | break; |
| 746 | case 0x10ec0262: |
| 747 | case 0x10ec0880: |
| 748 | case 0x10ec0882: |
| 749 | case 0x10ec0883: |
| 750 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 751 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 752 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 753 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 754 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 755 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 756 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 757 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 758 | #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] | 759 | case 0x10ec0267: |
| 760 | case 0x10ec0268: |
| 761 | snd_hda_codec_write(codec, 0x20, 0, |
| 762 | AC_VERB_SET_COEF_INDEX, 7); |
| 763 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 764 | AC_VERB_GET_PROC_COEF, 0); |
| 765 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 766 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 767 | snd_hda_codec_write(codec, 0x20, 0, |
| 768 | AC_VERB_SET_PROC_COEF, |
| 769 | tmp | 0x3000); |
| 770 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 771 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 772 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 773 | break; |
| 774 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 775 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 776 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 777 | /* |
| 778 | * Auto-Mute mode mixer enum support |
| 779 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 780 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 781 | struct snd_ctl_elem_info *uinfo) |
| 782 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 783 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 784 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 785 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 786 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 787 | }; |
| 788 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 789 | if (spec->automute_speaker_possible && spec->automute_lo_possible) |
| 790 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 791 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 795 | struct snd_ctl_elem_value *ucontrol) |
| 796 | { |
| 797 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 798 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 799 | unsigned int val = 0; |
| 800 | if (spec->automute_speaker) |
| 801 | val++; |
| 802 | if (spec->automute_lo) |
| 803 | val++; |
| 804 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 805 | ucontrol->value.enumerated.item[0] = val; |
| 806 | return 0; |
| 807 | } |
| 808 | |
| 809 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 810 | struct snd_ctl_elem_value *ucontrol) |
| 811 | { |
| 812 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 813 | struct alc_spec *spec = codec->spec; |
| 814 | |
| 815 | switch (ucontrol->value.enumerated.item[0]) { |
| 816 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 817 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 818 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 819 | spec->automute_speaker = 0; |
| 820 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 821 | break; |
| 822 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 823 | if (spec->automute_speaker_possible) { |
| 824 | if (!spec->automute_lo && spec->automute_speaker) |
| 825 | return 0; |
| 826 | spec->automute_speaker = 1; |
| 827 | spec->automute_lo = 0; |
| 828 | } else if (spec->automute_lo_possible) { |
| 829 | if (spec->automute_lo) |
| 830 | return 0; |
| 831 | spec->automute_lo = 1; |
| 832 | } else |
| 833 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 834 | break; |
| 835 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 836 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 837 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 838 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 839 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 840 | spec->automute_speaker = 1; |
| 841 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 842 | break; |
| 843 | default: |
| 844 | return -EINVAL; |
| 845 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 846 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 847 | return 1; |
| 848 | } |
| 849 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 850 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 851 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 852 | .name = "Auto-Mute Mode", |
| 853 | .info = alc_automute_mode_info, |
| 854 | .get = alc_automute_mode_get, |
| 855 | .put = alc_automute_mode_put, |
| 856 | }; |
| 857 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 858 | static struct snd_kcontrol_new * |
| 859 | alc_kcontrol_new(struct alc_spec *spec, const char *name, |
| 860 | const struct snd_kcontrol_new *temp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 861 | { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 862 | struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); |
| 863 | if (!knew) |
| 864 | return NULL; |
| 865 | *knew = *temp; |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 866 | if (name) |
| 867 | knew->name = kstrdup(name, GFP_KERNEL); |
| 868 | else if (knew->name) |
| 869 | knew->name = kstrdup(knew->name, GFP_KERNEL); |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 870 | if (!knew->name) |
| 871 | return NULL; |
| 872 | return knew; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 873 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 874 | |
| 875 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 876 | { |
| 877 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 878 | |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 879 | if (!alc_kcontrol_new(spec, NULL, &alc_automute_mode_enum)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 880 | return -ENOMEM; |
| 881 | return 0; |
| 882 | } |
| 883 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 884 | /* |
| 885 | * Check the availability of HP/line-out auto-mute; |
| 886 | * Set up appropriately if really supported |
| 887 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 888 | static int alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 889 | { |
| 890 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 891 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 892 | int present = 0; |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 893 | int i, err; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 894 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 895 | if (cfg->hp_pins[0]) |
| 896 | present++; |
| 897 | if (cfg->line_out_pins[0]) |
| 898 | present++; |
| 899 | if (cfg->speaker_pins[0]) |
| 900 | present++; |
| 901 | if (present < 2) /* need two different output types */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 902 | return 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 903 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 904 | if (!cfg->speaker_pins[0] && |
| 905 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 906 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 907 | sizeof(cfg->speaker_pins)); |
| 908 | cfg->speaker_outs = cfg->line_outs; |
| 909 | } |
| 910 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 911 | if (!cfg->hp_pins[0] && |
| 912 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 913 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 914 | sizeof(cfg->hp_pins)); |
| 915 | cfg->hp_outs = cfg->line_outs; |
| 916 | } |
| 917 | |
| 918 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 919 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 920 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 921 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 922 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 923 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 924 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 925 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 926 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 927 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 928 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 929 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 930 | if (cfg->speaker_outs) |
| 931 | for (i = 0; i < cfg->line_outs; i++) { |
| 932 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 933 | if (!is_jack_detectable(codec, nid)) |
| 934 | continue; |
| 935 | snd_printdd("realtek: Enable Line-Out " |
| 936 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 937 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 938 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 939 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 940 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 941 | spec->automute_lo_possible = spec->detect_hp; |
| 942 | } |
| 943 | |
| 944 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 945 | (spec->detect_hp || spec->detect_lo); |
| 946 | |
| 947 | spec->automute_lo = spec->automute_lo_possible; |
| 948 | spec->automute_speaker = spec->automute_speaker_possible; |
| 949 | |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 950 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 951 | /* create a control for automute mode */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 952 | err = alc_add_automute_mode_enum(codec); |
| 953 | if (err < 0) |
| 954 | return err; |
| 955 | } |
| 956 | return 0; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 957 | } |
| 958 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 959 | /* 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] | 960 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 961 | { |
| 962 | int i; |
| 963 | for (i = 0; i < nums; i++) |
| 964 | if (list[i] == nid) |
| 965 | return i; |
| 966 | return -1; |
| 967 | } |
| 968 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 969 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 970 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 971 | { |
| 972 | struct alc_spec *spec = codec->spec; |
| 973 | const struct hda_input_mux *imux; |
| 974 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 975 | imux = &spec->input_mux; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 976 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 977 | spec->imux_pins, imux->num_items); |
| 978 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 979 | spec->imux_pins, imux->num_items); |
| 980 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 981 | spec->imux_pins, imux->num_items); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 982 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 983 | return false; /* no corresponding imux */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 984 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 985 | snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, |
| 986 | ALC_MIC_EVENT, alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 987 | if (spec->dock_mic_pin) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 988 | snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, |
| 989 | ALC_MIC_EVENT, |
| 990 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 991 | return true; |
| 992 | } |
| 993 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 994 | /* |
| 995 | * Check the availability of auto-mic switch; |
| 996 | * Set up if really supported |
| 997 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 998 | static int alc_init_auto_mic(struct hda_codec *codec) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 999 | { |
| 1000 | struct alc_spec *spec = codec->spec; |
| 1001 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1002 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1003 | int i; |
| 1004 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1005 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1006 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1007 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1008 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1009 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1010 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1011 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1012 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1013 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1014 | if (fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1015 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1016 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1017 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1018 | fixed = nid; |
| 1019 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1020 | case INPUT_PIN_ATTR_UNUSED: |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1021 | return 0; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1022 | case INPUT_PIN_ATTR_DOCK: |
| 1023 | if (dock) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1024 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1025 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1026 | return 0; /* invalid type */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1027 | dock = nid; |
| 1028 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1029 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1030 | if (ext) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1031 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1032 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1033 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1034 | ext = nid; |
| 1035 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1036 | } |
| 1037 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1038 | if (!ext && dock) { |
| 1039 | ext = dock; |
| 1040 | dock = 0; |
| 1041 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1042 | if (!ext || !fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1043 | return 0; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1044 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1045 | return 0; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1046 | if (dock && !is_jack_detectable(codec, dock)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1047 | return 0; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1048 | |
| 1049 | /* check imux indices */ |
| 1050 | spec->ext_mic_pin = ext; |
| 1051 | spec->int_mic_pin = fixed; |
| 1052 | spec->dock_mic_pin = dock; |
| 1053 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1054 | if (!alc_auto_mic_check_imux(codec)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1055 | return 0; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1056 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1057 | spec->auto_mic = 1; |
| 1058 | spec->num_adc_nids = 1; |
| 1059 | spec->cur_mux[0] = spec->int_mic_idx; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1060 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1061 | ext, fixed, dock); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1062 | |
| 1063 | return 0; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1064 | } |
| 1065 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1066 | /* |
| 1067 | * Realtek SSID verification |
| 1068 | */ |
| 1069 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1070 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1071 | * the driver to ignore any present sku defines. |
| 1072 | */ |
| 1073 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1074 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1075 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1076 | const struct hda_fixup *fix, int action) |
| 1077 | { |
| 1078 | struct alc_spec *spec = codec->spec; |
| 1079 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1080 | spec->cdefine.fixup = 1; |
| 1081 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1082 | } |
| 1083 | } |
| 1084 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1085 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1086 | { |
| 1087 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1088 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1089 | struct alc_spec *spec = codec->spec; |
| 1090 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1091 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1092 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1093 | if (spec->cdefine.fixup) { |
| 1094 | ass = spec->cdefine.sku_cfg; |
| 1095 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1096 | return -1; |
| 1097 | goto do_sku; |
| 1098 | } |
| 1099 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1100 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1101 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1102 | goto do_sku; |
| 1103 | |
| 1104 | nid = 0x1d; |
| 1105 | if (codec->vendor_id == 0x10ec0260) |
| 1106 | nid = 0x17; |
| 1107 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1108 | |
| 1109 | if (!(ass & 1)) { |
| 1110 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1111 | codec->chip_name, ass); |
| 1112 | return -1; |
| 1113 | } |
| 1114 | |
| 1115 | /* check sum */ |
| 1116 | tmp = 0; |
| 1117 | for (i = 1; i < 16; i++) { |
| 1118 | if ((ass >> i) & 1) |
| 1119 | tmp++; |
| 1120 | } |
| 1121 | if (((ass >> 16) & 0xf) != tmp) |
| 1122 | return -1; |
| 1123 | |
| 1124 | spec->cdefine.port_connectivity = ass >> 30; |
| 1125 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1126 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1127 | spec->cdefine.customization = ass >> 8; |
| 1128 | do_sku: |
| 1129 | spec->cdefine.sku_cfg = ass; |
| 1130 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1131 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1132 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1133 | spec->cdefine.override = ass & 0x1; |
| 1134 | |
| 1135 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1136 | nid, spec->cdefine.sku_cfg); |
| 1137 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1138 | spec->cdefine.port_connectivity); |
| 1139 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1140 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1141 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1142 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1143 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1144 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1145 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1146 | |
| 1147 | return 0; |
| 1148 | } |
| 1149 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1150 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1151 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1152 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1153 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1154 | } |
| 1155 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1156 | /* check subsystem ID and set up device-specific initialization; |
| 1157 | * return 1 if initialized, 0 if invalid SSID |
| 1158 | */ |
| 1159 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1160 | * 31 ~ 16 : Manufacture ID |
| 1161 | * 15 ~ 8 : SKU ID |
| 1162 | * 7 ~ 0 : Assembly ID |
| 1163 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1164 | */ |
| 1165 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1166 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1167 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1168 | { |
| 1169 | unsigned int ass, tmp, i; |
| 1170 | unsigned nid; |
| 1171 | struct alc_spec *spec = codec->spec; |
| 1172 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1173 | if (spec->cdefine.fixup) { |
| 1174 | ass = spec->cdefine.sku_cfg; |
| 1175 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1176 | return 0; |
| 1177 | goto do_sku; |
| 1178 | } |
| 1179 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1180 | ass = codec->subsystem_id & 0xffff; |
| 1181 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1182 | goto do_sku; |
| 1183 | |
| 1184 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1185 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1186 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1187 | * 29~21 : reserve |
| 1188 | * 20 : PCBEEP input |
| 1189 | * 19~16 : Check sum (15:1) |
| 1190 | * 15~1 : Custom |
| 1191 | * 0 : override |
| 1192 | */ |
| 1193 | nid = 0x1d; |
| 1194 | if (codec->vendor_id == 0x10ec0260) |
| 1195 | nid = 0x17; |
| 1196 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1197 | snd_printd("realtek: No valid SSID, " |
| 1198 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1199 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1200 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1201 | return 0; |
| 1202 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1203 | return 0; |
| 1204 | |
| 1205 | /* check sum */ |
| 1206 | tmp = 0; |
| 1207 | for (i = 1; i < 16; i++) { |
| 1208 | if ((ass >> i) & 1) |
| 1209 | tmp++; |
| 1210 | } |
| 1211 | if (((ass >> 16) & 0xf) != tmp) |
| 1212 | return 0; |
| 1213 | do_sku: |
| 1214 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1215 | ass & 0xffff, codec->vendor_id); |
| 1216 | /* |
| 1217 | * 0 : override |
| 1218 | * 1 : Swap Jack |
| 1219 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1220 | * 3~5 : External Amplifier control |
| 1221 | * 7~6 : Reserved |
| 1222 | */ |
| 1223 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1224 | switch (tmp) { |
| 1225 | case 1: |
| 1226 | spec->init_amp = ALC_INIT_GPIO1; |
| 1227 | break; |
| 1228 | case 3: |
| 1229 | spec->init_amp = ALC_INIT_GPIO2; |
| 1230 | break; |
| 1231 | case 7: |
| 1232 | spec->init_amp = ALC_INIT_GPIO3; |
| 1233 | break; |
| 1234 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1235 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1236 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1237 | break; |
| 1238 | } |
| 1239 | |
| 1240 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1241 | * when the external headphone out jack is plugged" |
| 1242 | */ |
| 1243 | if (!(ass & 0x8000)) |
| 1244 | return 1; |
| 1245 | /* |
| 1246 | * 10~8 : Jack location |
| 1247 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1248 | * 14~13: Resvered |
| 1249 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1250 | * when the external headphone out jack is plugged" |
| 1251 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1252 | if (!spec->autocfg.hp_pins[0] && |
| 1253 | !(spec->autocfg.line_out_pins[0] && |
| 1254 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1255 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1256 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1257 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1258 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1259 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1260 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1261 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1262 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1263 | else if (tmp == 3) |
| 1264 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1265 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1266 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1267 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1268 | spec->autocfg.line_outs)) |
| 1269 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1270 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1271 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1272 | return 1; |
| 1273 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1274 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1275 | /* Check the validity of ALC subsystem-id |
| 1276 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1277 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1278 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1279 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1280 | struct alc_spec *spec = codec->spec; |
| 1281 | snd_printd("realtek: " |
| 1282 | "Enable default setup for auto mode as fallback\n"); |
| 1283 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1284 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1285 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1286 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1287 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1288 | * COEF access helper functions |
| 1289 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1290 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1291 | unsigned int coef_idx) |
| 1292 | { |
| 1293 | unsigned int val; |
| 1294 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1295 | coef_idx); |
| 1296 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1297 | AC_VERB_GET_PROC_COEF, 0); |
| 1298 | return val; |
| 1299 | } |
| 1300 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1301 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1302 | unsigned int coef_val) |
| 1303 | { |
| 1304 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1305 | coef_idx); |
| 1306 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1307 | coef_val); |
| 1308 | } |
| 1309 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1310 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1311 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1312 | { |
| 1313 | struct alc_spec *spec = codec->spec; |
| 1314 | if (!spec->coef0) |
| 1315 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1316 | return spec->coef0; |
| 1317 | } |
| 1318 | |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1319 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 1320 | hda_nid_t pin, int pin_type, |
| 1321 | hda_nid_t dac); |
| 1322 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 1323 | bool is_digital); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1324 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 1325 | hda_nid_t to_nid, int with_aa_mix, |
| 1326 | struct nid_path *path); |
| 1327 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 1328 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 1329 | int with_aa_mix); |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1330 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1331 | /* |
| 1332 | * Digital I/O handling |
| 1333 | */ |
| 1334 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1335 | /* set right pin controls for digital I/O */ |
| 1336 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1337 | { |
| 1338 | struct alc_spec *spec = codec->spec; |
| 1339 | int i; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1340 | hda_nid_t pin; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1341 | |
| 1342 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1343 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1344 | if (!pin) |
| 1345 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1346 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1347 | } |
| 1348 | pin = spec->autocfg.dig_in_pin; |
| 1349 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1350 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1351 | } |
| 1352 | |
| 1353 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1354 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1355 | { |
| 1356 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1357 | int i, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1358 | hda_nid_t dig_nid; |
| 1359 | |
| 1360 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1361 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1362 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1363 | hda_nid_t pin = spec->autocfg.dig_out_pins[i]; |
| 1364 | dig_nid = alc_auto_look_for_dac(codec, pin, true); |
| 1365 | if (!dig_nid) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1366 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1367 | if (!add_new_nid_path(codec, dig_nid, pin, 2)) |
| 1368 | continue; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1369 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1370 | spec->multiout.dig_out_nid = dig_nid; |
| 1371 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1372 | } else { |
| 1373 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1374 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1375 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1376 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1377 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1378 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1382 | dig_nid = codec->start_nid; |
| 1383 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1384 | struct nid_path *path; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1385 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1386 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1387 | continue; |
| 1388 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1389 | continue; |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1390 | path = add_new_nid_path(codec, spec->autocfg.dig_in_pin, |
| 1391 | dig_nid, 2); |
| 1392 | if (path) { |
| 1393 | path->active = true; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1394 | spec->dig_in_nid = dig_nid; |
| 1395 | break; |
| 1396 | } |
| 1397 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1398 | } |
| 1399 | } |
| 1400 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1401 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1402 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1403 | */ |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1404 | #define alc_cap_vol_info snd_hda_mixer_amp_volume_info |
| 1405 | #define alc_cap_vol_get snd_hda_mixer_amp_volume_get |
| 1406 | #define alc_cap_vol_tlv snd_hda_mixer_amp_tlv |
| 1407 | |
| 1408 | typedef int (*put_call_t)(struct snd_kcontrol *kcontrol, |
| 1409 | struct snd_ctl_elem_value *ucontrol); |
| 1410 | |
| 1411 | static int alc_cap_put_caller(struct snd_kcontrol *kcontrol, |
| 1412 | struct snd_ctl_elem_value *ucontrol, |
| 1413 | put_call_t func, int type) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1414 | { |
| 1415 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1416 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1417 | const struct hda_input_mux *imux; |
| 1418 | struct nid_path *path; |
| 1419 | int i, adc_idx, err = 0; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1420 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1421 | imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1422 | adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1423 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1424 | codec->cached_write = 1; |
| 1425 | for (i = 0; i < imux->num_items; i++) { |
| 1426 | path = get_nid_path(codec, spec->imux_pins[i], |
| 1427 | get_adc_nid(codec, adc_idx, i)); |
| 1428 | if (!path->ctls[type]) |
| 1429 | continue; |
| 1430 | kcontrol->private_value = path->ctls[type]; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1431 | err = func(kcontrol, ucontrol); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1432 | if (err < 0) |
| 1433 | goto error; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1434 | } |
| 1435 | error: |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1436 | codec->cached_write = 0; |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1437 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1438 | snd_hda_codec_resume_amp(codec); |
| 1439 | if (err >= 0 && type == NID_PATH_MUTE_CTL && |
| 1440 | spec->inv_dmic_fixup && spec->inv_dmic_muted) |
| 1441 | alc_inv_dmic_sync_adc(codec, adc_idx); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1442 | return err; |
| 1443 | } |
| 1444 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1445 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1446 | struct snd_ctl_elem_value *ucontrol) |
| 1447 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1448 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1449 | snd_hda_mixer_amp_volume_put, |
| 1450 | NID_PATH_VOL_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | /* capture mixer elements */ |
| 1454 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1455 | #define alc_cap_sw_get snd_hda_mixer_amp_switch_get |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1456 | |
| 1457 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1458 | struct snd_ctl_elem_value *ucontrol) |
| 1459 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1460 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1461 | snd_hda_mixer_amp_switch_put, |
| 1462 | NID_PATH_MUTE_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1463 | } |
| 1464 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1465 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) |
| 1466 | { |
| 1467 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1468 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1469 | struct nid_path *path; |
| 1470 | hda_nid_t nid; |
| 1471 | int i, dir, parm; |
| 1472 | unsigned int val; |
| 1473 | |
| 1474 | for (i = 0; i < imux->num_items; i++) { |
| 1475 | if (spec->imux_pins[i] == spec->inv_dmic_pin) |
| 1476 | break; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1477 | } |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1478 | if (i >= imux->num_items) |
| 1479 | return; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1480 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1481 | path = get_nid_path(codec, spec->inv_dmic_pin, |
| 1482 | get_adc_nid(codec, adc_idx, i)); |
| 1483 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 1484 | if (!val) |
| 1485 | return; |
| 1486 | nid = get_amp_nid_(val); |
| 1487 | dir = get_amp_direction_(val); |
| 1488 | parm = AC_AMP_SET_RIGHT | |
| 1489 | (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1490 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1491 | /* we care only right channel */ |
| 1492 | val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1493 | if (val & 0x80) /* if already muted, we don't need to touch */ |
| 1494 | return; |
| 1495 | val |= 0x80; |
| 1496 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1497 | parm | val); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1498 | } |
| 1499 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1500 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1501 | * Inverted digital-mic handling |
| 1502 | * |
| 1503 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1504 | * gives the additional mute only to the right channel of the digital mic |
| 1505 | * capture stream. This is a workaround for avoiding the almost silence |
| 1506 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1507 | * digital mic unit. |
| 1508 | * |
| 1509 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1510 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1511 | * without caching so that the cache can still keep the original value. |
| 1512 | * The cached value is then restored when the flag is set off or any other |
| 1513 | * than d-mic is used as the current input source. |
| 1514 | */ |
| 1515 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1516 | { |
| 1517 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1518 | int src, nums; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1519 | |
| 1520 | if (!spec->inv_dmic_fixup) |
| 1521 | return; |
| 1522 | if (!spec->inv_dmic_muted && !force) |
| 1523 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1524 | nums = spec->dyn_adc_switch ? 1 : spec->num_adc_nids; |
| 1525 | for (src = 0; src < nums; src++) { |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1526 | bool dmic_fixup = false; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1527 | |
| 1528 | if (spec->inv_dmic_muted && |
| 1529 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1530 | dmic_fixup = true; |
| 1531 | if (!dmic_fixup && !force) |
| 1532 | continue; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1533 | alc_inv_dmic_sync_adc(codec, src); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1538 | struct snd_ctl_elem_value *ucontrol) |
| 1539 | { |
| 1540 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1541 | struct alc_spec *spec = codec->spec; |
| 1542 | |
| 1543 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1544 | return 0; |
| 1545 | } |
| 1546 | |
| 1547 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1548 | struct snd_ctl_elem_value *ucontrol) |
| 1549 | { |
| 1550 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1551 | struct alc_spec *spec = codec->spec; |
| 1552 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1553 | |
| 1554 | if (val == spec->inv_dmic_muted) |
| 1555 | return 0; |
| 1556 | spec->inv_dmic_muted = val; |
| 1557 | alc_inv_dmic_sync(codec, true); |
| 1558 | return 0; |
| 1559 | } |
| 1560 | |
| 1561 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1562 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 1563 | .name = "Inverted Internal Mic Capture Switch", |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1564 | .info = snd_ctl_boolean_mono_info, |
| 1565 | .get = alc_inv_dmic_sw_get, |
| 1566 | .put = alc_inv_dmic_sw_put, |
| 1567 | }; |
| 1568 | |
| 1569 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1570 | { |
| 1571 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 1572 | |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 1573 | if (!alc_kcontrol_new(spec, NULL, &alc_inv_dmic_sw)) |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1574 | return -ENOMEM; |
| 1575 | spec->inv_dmic_fixup = 1; |
| 1576 | spec->inv_dmic_muted = 0; |
| 1577 | spec->inv_dmic_pin = nid; |
| 1578 | return 0; |
| 1579 | } |
| 1580 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1581 | /* typically the digital mic is put at node 0x12 */ |
| 1582 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1583 | const struct alc_fixup *fix, int action) |
| 1584 | { |
| 1585 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1586 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1587 | } |
| 1588 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1589 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1590 | * virtual master controls |
| 1591 | */ |
| 1592 | |
| 1593 | /* |
| 1594 | * slave controls for virtual master |
| 1595 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1596 | static const char * const alc_slave_pfxs[] = { |
| 1597 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1598 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1599 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1600 | NULL, |
| 1601 | }; |
| 1602 | |
| 1603 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1604 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1606 | |
| 1607 | static void alc_free_kctls(struct hda_codec *codec); |
| 1608 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1609 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1610 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1611 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1612 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1613 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1614 | { } /* end */ |
| 1615 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1616 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1617 | |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 1618 | static int alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | { |
| 1620 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1621 | int i, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1622 | |
| 1623 | for (i = 0; i < spec->num_mixers; i++) { |
| 1624 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1625 | if (err < 0) |
| 1626 | return err; |
| 1627 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1629 | err = snd_hda_create_dig_out_ctls(codec, |
| 1630 | spec->multiout.dig_out_nid, |
| 1631 | spec->multiout.dig_out_nid, |
| 1632 | spec->pcm_rec[1].pcm_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | if (err < 0) |
| 1634 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1635 | if (!spec->no_analog) { |
| 1636 | err = snd_hda_create_spdif_share_sw(codec, |
| 1637 | &spec->multiout); |
| 1638 | if (err < 0) |
| 1639 | return err; |
| 1640 | spec->multiout.share_spdif = 1; |
| 1641 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | } |
| 1643 | if (spec->dig_in_nid) { |
| 1644 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1645 | if (err < 0) |
| 1646 | return err; |
| 1647 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1648 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1649 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1650 | /* create beep controls if needed */ |
| 1651 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1652 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1653 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1654 | struct snd_kcontrol *kctl; |
| 1655 | kctl = snd_ctl_new1(knew, codec); |
| 1656 | if (!kctl) |
| 1657 | return -ENOMEM; |
| 1658 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1659 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1660 | if (err < 0) |
| 1661 | return err; |
| 1662 | } |
| 1663 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1664 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1665 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1666 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1667 | if (!spec->no_analog && |
| 1668 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1669 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1670 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1671 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1672 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1673 | vmaster_tlv, alc_slave_pfxs, |
| 1674 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1675 | if (err < 0) |
| 1676 | return err; |
| 1677 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1678 | if (!spec->no_analog && |
| 1679 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1680 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1681 | NULL, alc_slave_pfxs, |
| 1682 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1683 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1684 | if (err < 0) |
| 1685 | return err; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 1686 | if (spec->vmaster_mute.hook) |
| 1687 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1688 | } |
| 1689 | |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1690 | alc_free_kctls(codec); /* no longer needed */ |
| 1691 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1692 | if (spec->shared_mic_hp) { |
| 1693 | int err; |
| 1694 | int nid = spec->autocfg.inputs[1].pin; |
| 1695 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1696 | if (err < 0) |
| 1697 | return err; |
| 1698 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1699 | if (err < 0) |
| 1700 | return err; |
| 1701 | } |
| 1702 | |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 1703 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1704 | if (err < 0) |
| 1705 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1706 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1707 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1708 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1709 | } |
| 1710 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1711 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1713 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1714 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1715 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1716 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1717 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | static int alc_init(struct hda_codec *codec) |
| 1719 | { |
| 1720 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1721 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 1722 | if (spec->init_hook) |
| 1723 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 1724 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1725 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1726 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1727 | |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame^] | 1728 | snd_hda_apply_verbs(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1729 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1730 | |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 1731 | if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) |
| 1732 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 1733 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1734 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 1735 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 1736 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | return 0; |
| 1738 | } |
| 1739 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 1740 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1741 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 1742 | { |
| 1743 | struct alc_spec *spec = codec->spec; |
| 1744 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 1745 | } |
| 1746 | #endif |
| 1747 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | /* |
| 1749 | * Analog playback callbacks |
| 1750 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1751 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1753 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | { |
| 1755 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1756 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 1757 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1758 | } |
| 1759 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1760 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | struct hda_codec *codec, |
| 1762 | unsigned int stream_tag, |
| 1763 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1764 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1765 | { |
| 1766 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1767 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 1768 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | } |
| 1770 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1771 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1772 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1773 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1774 | { |
| 1775 | struct alc_spec *spec = codec->spec; |
| 1776 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1777 | } |
| 1778 | |
| 1779 | /* |
| 1780 | * Digital out |
| 1781 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1782 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1784 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1785 | { |
| 1786 | struct alc_spec *spec = codec->spec; |
| 1787 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1788 | } |
| 1789 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1790 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1791 | struct hda_codec *codec, |
| 1792 | unsigned int stream_tag, |
| 1793 | unsigned int format, |
| 1794 | struct snd_pcm_substream *substream) |
| 1795 | { |
| 1796 | struct alc_spec *spec = codec->spec; |
| 1797 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1798 | stream_tag, format, substream); |
| 1799 | } |
| 1800 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1801 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 1802 | struct hda_codec *codec, |
| 1803 | struct snd_pcm_substream *substream) |
| 1804 | { |
| 1805 | struct alc_spec *spec = codec->spec; |
| 1806 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 1807 | } |
| 1808 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1809 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1810 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1811 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1812 | { |
| 1813 | struct alc_spec *spec = codec->spec; |
| 1814 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1815 | } |
| 1816 | |
| 1817 | /* |
| 1818 | * Analog capture |
| 1819 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1820 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | struct hda_codec *codec, |
| 1822 | unsigned int stream_tag, |
| 1823 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1824 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | { |
| 1826 | struct alc_spec *spec = codec->spec; |
| 1827 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1828 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | stream_tag, 0, format); |
| 1830 | return 0; |
| 1831 | } |
| 1832 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1833 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1834 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1835 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | { |
| 1837 | struct alc_spec *spec = codec->spec; |
| 1838 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 1839 | snd_hda_codec_cleanup_stream(codec, |
| 1840 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1841 | return 0; |
| 1842 | } |
| 1843 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1844 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1845 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1846 | struct hda_codec *codec, |
| 1847 | unsigned int stream_tag, |
| 1848 | unsigned int format, |
| 1849 | struct snd_pcm_substream *substream) |
| 1850 | { |
| 1851 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1852 | 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] | 1853 | spec->cur_adc_stream_tag = stream_tag; |
| 1854 | spec->cur_adc_format = format; |
| 1855 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 1856 | return 0; |
| 1857 | } |
| 1858 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1859 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1860 | struct hda_codec *codec, |
| 1861 | struct snd_pcm_substream *substream) |
| 1862 | { |
| 1863 | struct alc_spec *spec = codec->spec; |
| 1864 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 1865 | spec->cur_adc = 0; |
| 1866 | return 0; |
| 1867 | } |
| 1868 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1869 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1870 | .substreams = 1, |
| 1871 | .channels_min = 2, |
| 1872 | .channels_max = 2, |
| 1873 | .nid = 0, /* fill later */ |
| 1874 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1875 | .prepare = dyn_adc_capture_pcm_prepare, |
| 1876 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1877 | }, |
| 1878 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1879 | |
| 1880 | /* |
| 1881 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1882 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1883 | .substreams = 1, |
| 1884 | .channels_min = 2, |
| 1885 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1886 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1887 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1888 | .open = alc_playback_pcm_open, |
| 1889 | .prepare = alc_playback_pcm_prepare, |
| 1890 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | }, |
| 1892 | }; |
| 1893 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1894 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1895 | .substreams = 1, |
| 1896 | .channels_min = 2, |
| 1897 | .channels_max = 2, |
| 1898 | /* NID is set in alc_build_pcms */ |
| 1899 | }; |
| 1900 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1901 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1902 | .substreams = 1, |
| 1903 | .channels_min = 2, |
| 1904 | .channels_max = 2, |
| 1905 | /* NID is set in alc_build_pcms */ |
| 1906 | }; |
| 1907 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1908 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1909 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1910 | .channels_min = 2, |
| 1911 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1912 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1914 | .prepare = alc_alt_capture_pcm_prepare, |
| 1915 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | }, |
| 1917 | }; |
| 1918 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1919 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | .substreams = 1, |
| 1921 | .channels_min = 2, |
| 1922 | .channels_max = 2, |
| 1923 | /* NID is set in alc_build_pcms */ |
| 1924 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1925 | .open = alc_dig_playback_pcm_open, |
| 1926 | .close = alc_dig_playback_pcm_close, |
| 1927 | .prepare = alc_dig_playback_pcm_prepare, |
| 1928 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1929 | }, |
| 1930 | }; |
| 1931 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1932 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1933 | .substreams = 1, |
| 1934 | .channels_min = 2, |
| 1935 | .channels_max = 2, |
| 1936 | /* NID is set in alc_build_pcms */ |
| 1937 | }; |
| 1938 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1939 | /* 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] | 1940 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1941 | .substreams = 0, |
| 1942 | .channels_min = 0, |
| 1943 | .channels_max = 0, |
| 1944 | }; |
| 1945 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1946 | static int alc_build_pcms(struct hda_codec *codec) |
| 1947 | { |
| 1948 | struct alc_spec *spec = codec->spec; |
| 1949 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1950 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 1951 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1952 | int i; |
| 1953 | |
| 1954 | codec->num_pcms = 1; |
| 1955 | codec->pcm_info = info; |
| 1956 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1957 | if (spec->no_analog) |
| 1958 | goto skip_analog; |
| 1959 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 1960 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 1961 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1962 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1963 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 1964 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1965 | p = spec->stream_analog_playback; |
| 1966 | if (!p) |
| 1967 | p = &alc_pcm_analog_playback; |
| 1968 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1969 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 1970 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 1971 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 1972 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 1973 | spec->autocfg.line_outs == 2) |
| 1974 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 1975 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1976 | } |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1977 | if (spec->num_adc_nids) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1978 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1979 | if (!p) { |
| 1980 | if (spec->dyn_adc_switch) |
| 1981 | p = &dyn_adc_pcm_analog_capture; |
| 1982 | else |
| 1983 | p = &alc_pcm_analog_capture; |
| 1984 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1985 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1986 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1987 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1988 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1989 | if (spec->channel_mode) { |
| 1990 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 1991 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 1992 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 1993 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 1994 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | } |
| 1996 | } |
| 1997 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1998 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 1999 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2001 | snprintf(spec->stream_name_digital, |
| 2002 | sizeof(spec->stream_name_digital), |
| 2003 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2004 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2005 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2006 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2007 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2008 | if (spec->dig_out_type) |
| 2009 | info->pcm_type = spec->dig_out_type; |
| 2010 | else |
| 2011 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2012 | if (spec->multiout.dig_out_nid) { |
| 2013 | p = spec->stream_digital_playback; |
| 2014 | if (!p) |
| 2015 | p = &alc_pcm_digital_playback; |
| 2016 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2017 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2018 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2019 | if (spec->dig_in_nid) { |
| 2020 | p = spec->stream_digital_capture; |
| 2021 | if (!p) |
| 2022 | p = &alc_pcm_digital_capture; |
| 2023 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2025 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2026 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2027 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | } |
| 2029 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2030 | if (spec->no_analog) |
| 2031 | return 0; |
| 2032 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2033 | /* If the use of more than one ADC is requested for the current |
| 2034 | * model, configure a second analog capture-only PCM. |
| 2035 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2036 | have_multi_adcs = (spec->num_adc_nids > 1) && |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2037 | !spec->dyn_adc_switch && !spec->auto_mic; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2038 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2039 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2040 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2041 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2042 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2043 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2044 | p = spec->stream_analog_alt_playback; |
| 2045 | if (!p) |
| 2046 | p = &alc_pcm_analog_alt_playback; |
| 2047 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2048 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2049 | spec->alt_dac_nid; |
| 2050 | } else { |
| 2051 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2052 | alc_pcm_null_stream; |
| 2053 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2054 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2055 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2056 | p = spec->stream_analog_alt_capture; |
| 2057 | if (!p) |
| 2058 | p = &alc_pcm_analog_alt_capture; |
| 2059 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2060 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2061 | spec->adc_nids[1]; |
| 2062 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2063 | spec->num_adc_nids - 1; |
| 2064 | } else { |
| 2065 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2066 | alc_pcm_null_stream; |
| 2067 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2068 | } |
| 2069 | } |
| 2070 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | return 0; |
| 2072 | } |
| 2073 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2074 | static inline void alc_shutup(struct hda_codec *codec) |
| 2075 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2076 | struct alc_spec *spec = codec->spec; |
| 2077 | |
| 2078 | if (spec && spec->shutup) |
| 2079 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2080 | snd_hda_shutup_pins(codec); |
| 2081 | } |
| 2082 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2083 | static void alc_free_kctls(struct hda_codec *codec) |
| 2084 | { |
| 2085 | struct alc_spec *spec = codec->spec; |
| 2086 | |
| 2087 | if (spec->kctls.list) { |
| 2088 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2089 | int i; |
| 2090 | for (i = 0; i < spec->kctls.used; i++) |
| 2091 | kfree(kctl[i].name); |
| 2092 | } |
| 2093 | snd_array_free(&spec->kctls); |
| 2094 | } |
| 2095 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2096 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2097 | { |
| 2098 | struct alc_spec *spec = codec->spec; |
| 2099 | if (spec->bind_ctls.list) { |
| 2100 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2101 | int i; |
| 2102 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2103 | kfree(ctl[i]); |
| 2104 | } |
| 2105 | snd_array_free(&spec->bind_ctls); |
| 2106 | } |
| 2107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | static void alc_free(struct hda_codec *codec) |
| 2109 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2110 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2111 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2112 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2113 | return; |
| 2114 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2115 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2116 | alc_free_bind_ctls(codec); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2117 | snd_array_free(&spec->paths); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2118 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2119 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2120 | } |
| 2121 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2122 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2123 | static void alc_power_eapd(struct hda_codec *codec) |
| 2124 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2125 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2126 | } |
| 2127 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2128 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2129 | { |
| 2130 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2131 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2132 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2133 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2134 | return 0; |
| 2135 | } |
| 2136 | #endif |
| 2137 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2138 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2139 | static int alc_resume(struct hda_codec *codec) |
| 2140 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2141 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2142 | codec->patch_ops.init(codec); |
| 2143 | snd_hda_codec_resume_amp(codec); |
| 2144 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2145 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2146 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2147 | return 0; |
| 2148 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2149 | #endif |
| 2150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2151 | /* |
| 2152 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2153 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | .build_controls = alc_build_controls, |
| 2155 | .build_pcms = alc_build_pcms, |
| 2156 | .init = alc_init, |
| 2157 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2158 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2159 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2160 | .resume = alc_resume, |
| 2161 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2162 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2163 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2164 | .check_power_status = alc_check_power_status, |
| 2165 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2166 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | }; |
| 2168 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2169 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2170 | /* replace the codec chip_name with the given string */ |
| 2171 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2172 | { |
| 2173 | kfree(codec->chip_name); |
| 2174 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2175 | if (!codec->chip_name) { |
| 2176 | alc_free(codec); |
| 2177 | return -ENOMEM; |
| 2178 | } |
| 2179 | return 0; |
| 2180 | } |
| 2181 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2182 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2183 | * Rename codecs appropriately from COEF value |
| 2184 | */ |
| 2185 | struct alc_codec_rename_table { |
| 2186 | unsigned int vendor_id; |
| 2187 | unsigned short coef_mask; |
| 2188 | unsigned short coef_bits; |
| 2189 | const char *name; |
| 2190 | }; |
| 2191 | |
| 2192 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2193 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2194 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2195 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2196 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2197 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2198 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2199 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2200 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2201 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2202 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2203 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2204 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2205 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2206 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2207 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2208 | { } /* terminator */ |
| 2209 | }; |
| 2210 | |
| 2211 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2212 | { |
| 2213 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2214 | |
| 2215 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2216 | if (p->vendor_id != codec->vendor_id) |
| 2217 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2218 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2219 | return alc_codec_rename(codec, p->name); |
| 2220 | } |
| 2221 | return 0; |
| 2222 | } |
| 2223 | |
| 2224 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2225 | * Automatic parse of I/O pins from the BIOS configuration |
| 2226 | */ |
| 2227 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2228 | enum { |
| 2229 | ALC_CTL_WIDGET_VOL, |
| 2230 | ALC_CTL_WIDGET_MUTE, |
| 2231 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2232 | ALC_CTL_BIND_VOL, |
| 2233 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2234 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2235 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2236 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2237 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2238 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2239 | HDA_BIND_VOL(NULL, 0), |
| 2240 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2241 | }; |
| 2242 | |
| 2243 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2244 | 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] | 2245 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2246 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2247 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2248 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 2249 | knew = alc_kcontrol_new(spec, name, &alc_control_templates[type]); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2250 | if (!knew) |
| 2251 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2252 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2253 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2254 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2255 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2256 | return 0; |
| 2257 | } |
| 2258 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2259 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2260 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2261 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2262 | { |
| 2263 | char name[32]; |
| 2264 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2265 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2266 | } |
| 2267 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2268 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2269 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2270 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2271 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2272 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2273 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2274 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2275 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2276 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2277 | static const char * const channel_name[4] = { |
| 2278 | "Front", "Surround", "CLFE", "Side" |
| 2279 | }; |
| 2280 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2281 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2282 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2283 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2284 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2285 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2286 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2287 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2288 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | 52a8efa | 2012-12-18 17:33:04 +0100 | [diff] [blame] | 2289 | return spec->vmaster_mute.hook ? "PCM" : "Master"; |
| 2290 | |
| 2291 | /* if there is really a single DAC used in the whole output paths, |
| 2292 | * use it master (or "PCM" if a vmaster hook is present) |
| 2293 | */ |
| 2294 | if (spec->multiout.num_dacs == 1 && !spec->mixer_nid && |
| 2295 | !spec->multiout.hp_out_nid[0] && !spec->multiout.extra_out_nid[0]) |
| 2296 | return spec->vmaster_mute.hook ? "PCM" : "Master"; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2297 | |
| 2298 | switch (cfg->line_out_type) { |
| 2299 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2300 | if (cfg->line_outs == 1) |
| 2301 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2302 | if (cfg->line_outs == 2) |
| 2303 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2304 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2305 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2306 | /* for multi-io case, only the primary out */ |
| 2307 | if (ch && spec->multi_ios) |
| 2308 | break; |
| 2309 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2310 | return "Headphone"; |
| 2311 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2312 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2313 | return "PCM"; |
| 2314 | break; |
| 2315 | } |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2316 | if (ch >= ARRAY_SIZE(channel_name)) { |
| 2317 | snd_BUG(); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2318 | return "PCM"; |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2319 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2320 | |
| 2321 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2322 | } |
| 2323 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2324 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2325 | /* add the powersave loopback-list entry */ |
| 2326 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2327 | { |
| 2328 | struct hda_amp_list *list; |
| 2329 | |
| 2330 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2331 | return; |
| 2332 | list = spec->loopback_list + spec->num_loopbacks; |
| 2333 | list->nid = mix; |
| 2334 | list->dir = HDA_INPUT; |
| 2335 | list->idx = idx; |
| 2336 | spec->num_loopbacks++; |
| 2337 | spec->loopback.amplist = spec->loopback_list; |
| 2338 | } |
| 2339 | #else |
| 2340 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2341 | #endif |
| 2342 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2343 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2344 | 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] | 2345 | const char *ctlname, int ctlidx, |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2346 | hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2347 | { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2348 | struct alc_spec *spec = codec->spec; |
| 2349 | struct nid_path *path; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2350 | unsigned int val; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2351 | int err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2352 | |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2353 | if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && |
| 2354 | !nid_has_mute(codec, mix_nid, HDA_INPUT)) |
| 2355 | return 0; /* no need for analog loopback */ |
| 2356 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2357 | path = add_new_nid_path(codec, pin, mix_nid, 2); |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2358 | if (!path) |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2359 | return -EINVAL; |
| 2360 | |
| 2361 | idx = path->idx[path->depth - 1]; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2362 | if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2363 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2364 | 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] | 2365 | if (err < 0) |
| 2366 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2367 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2368 | } |
| 2369 | |
| 2370 | if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2371 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2372 | 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] | 2373 | if (err < 0) |
| 2374 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2375 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2376 | } |
| 2377 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2378 | path->active = true; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2379 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2380 | return 0; |
| 2381 | } |
| 2382 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2383 | 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] | 2384 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2385 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2386 | return (pincap & AC_PINCAP_IN) != 0; |
| 2387 | } |
| 2388 | |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2389 | /* check whether the given two widgets can be connected */ |
| 2390 | static bool is_reachable_path(struct hda_codec *codec, |
| 2391 | hda_nid_t from_nid, hda_nid_t to_nid) |
| 2392 | { |
| 2393 | if (!from_nid || !to_nid) |
| 2394 | return false; |
| 2395 | return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; |
| 2396 | } |
| 2397 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2398 | /* Parse the codec tree and retrieve ADCs */ |
| 2399 | static int alc_auto_fill_adc_nids(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2400 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2401 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2402 | hda_nid_t nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2403 | hda_nid_t *adc_nids = spec->adc_nids; |
| 2404 | int max_nums = ARRAY_SIZE(spec->adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2405 | int i, nums = 0; |
| 2406 | |
| 2407 | nid = codec->start_nid; |
| 2408 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2409 | unsigned int caps = get_wcaps(codec, nid); |
| 2410 | int type = get_wcaps_type(caps); |
| 2411 | |
| 2412 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2413 | continue; |
| 2414 | adc_nids[nums] = nid; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2415 | if (++nums >= max_nums) |
| 2416 | break; |
| 2417 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2418 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2419 | return nums; |
| 2420 | } |
| 2421 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2422 | /* filter out invalid adc_nids that don't give all active input pins; |
| 2423 | * if needed, check whether dynamic ADC-switching is available |
| 2424 | */ |
| 2425 | static int check_dyn_adc_switch(struct hda_codec *codec) |
| 2426 | { |
| 2427 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2428 | struct hda_input_mux *imux = &spec->input_mux; |
| 2429 | hda_nid_t adc_nids[ARRAY_SIZE(spec->adc_nids)]; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2430 | int i, n, nums; |
| 2431 | hda_nid_t pin, adc; |
| 2432 | |
| 2433 | again: |
| 2434 | nums = 0; |
| 2435 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2436 | adc = spec->adc_nids[n]; |
| 2437 | for (i = 0; i < imux->num_items; i++) { |
| 2438 | pin = spec->imux_pins[i]; |
| 2439 | if (!is_reachable_path(codec, pin, adc)) |
| 2440 | break; |
| 2441 | } |
| 2442 | if (i >= imux->num_items) |
| 2443 | adc_nids[nums++] = adc; |
| 2444 | } |
| 2445 | |
| 2446 | if (!nums) { |
| 2447 | if (spec->shared_mic_hp) { |
| 2448 | spec->shared_mic_hp = 0; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2449 | imux->num_items = 1; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2450 | goto again; |
| 2451 | } |
| 2452 | |
| 2453 | /* check whether ADC-switch is possible */ |
| 2454 | for (i = 0; i < imux->num_items; i++) { |
| 2455 | pin = spec->imux_pins[i]; |
| 2456 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2457 | adc = spec->adc_nids[n]; |
| 2458 | if (is_reachable_path(codec, pin, adc)) { |
| 2459 | spec->dyn_adc_idx[i] = n; |
| 2460 | break; |
| 2461 | } |
| 2462 | } |
| 2463 | } |
| 2464 | |
| 2465 | snd_printdd("realtek: enabling ADC switching\n"); |
| 2466 | spec->dyn_adc_switch = 1; |
| 2467 | } else if (nums != spec->num_adc_nids) { |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2468 | memcpy(spec->adc_nids, adc_nids, nums * sizeof(hda_nid_t)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2469 | spec->num_adc_nids = nums; |
| 2470 | } |
| 2471 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2472 | if (imux->num_items == 1 || spec->shared_mic_hp) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2473 | snd_printdd("realtek: reducing to a single ADC\n"); |
| 2474 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 2475 | } |
| 2476 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2477 | /* single index for individual volumes ctls */ |
| 2478 | if (!spec->dyn_adc_switch && spec->multi_cap_vol) |
| 2479 | spec->num_adc_nids = 1; |
| 2480 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2481 | return 0; |
| 2482 | } |
| 2483 | |
| 2484 | /* templates for capture controls */ |
| 2485 | static const struct snd_kcontrol_new cap_src_temp = { |
| 2486 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2487 | .name = "Input Source", |
| 2488 | .info = alc_mux_enum_info, |
| 2489 | .get = alc_mux_enum_get, |
| 2490 | .put = alc_mux_enum_put, |
| 2491 | }; |
| 2492 | |
| 2493 | static const struct snd_kcontrol_new cap_vol_temp = { |
| 2494 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2495 | .name = "Capture Volume", |
| 2496 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2497 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2498 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), |
| 2499 | .info = alc_cap_vol_info, |
| 2500 | .get = alc_cap_vol_get, |
| 2501 | .put = alc_cap_vol_put, |
| 2502 | .tlv = { .c = alc_cap_vol_tlv }, |
| 2503 | }; |
| 2504 | |
| 2505 | static const struct snd_kcontrol_new cap_sw_temp = { |
| 2506 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2507 | .name = "Capture Switch", |
| 2508 | .info = alc_cap_sw_info, |
| 2509 | .get = alc_cap_sw_get, |
| 2510 | .put = alc_cap_sw_put, |
| 2511 | }; |
| 2512 | |
| 2513 | static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path) |
| 2514 | { |
| 2515 | hda_nid_t nid; |
| 2516 | int i, depth; |
| 2517 | |
| 2518 | path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; |
| 2519 | for (depth = 0; depth < 3; depth++) { |
| 2520 | if (depth >= path->depth) |
| 2521 | return -EINVAL; |
| 2522 | i = path->depth - depth - 1; |
| 2523 | nid = path->path[i]; |
| 2524 | if (!path->ctls[NID_PATH_VOL_CTL]) { |
| 2525 | if (nid_has_volume(codec, nid, HDA_OUTPUT)) |
| 2526 | path->ctls[NID_PATH_VOL_CTL] = |
| 2527 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2528 | else if (nid_has_volume(codec, nid, HDA_INPUT)) { |
| 2529 | int idx = path->idx[i]; |
| 2530 | if (!depth && codec->single_adc_amp) |
| 2531 | idx = 0; |
| 2532 | path->ctls[NID_PATH_VOL_CTL] = |
| 2533 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2534 | } |
| 2535 | } |
| 2536 | if (!path->ctls[NID_PATH_MUTE_CTL]) { |
| 2537 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2538 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2539 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2540 | else if (nid_has_mute(codec, nid, HDA_INPUT)) { |
| 2541 | int idx = path->idx[i]; |
| 2542 | if (!depth && codec->single_adc_amp) |
| 2543 | idx = 0; |
| 2544 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2545 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2546 | } |
| 2547 | } |
| 2548 | } |
| 2549 | return 0; |
| 2550 | } |
| 2551 | |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2552 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs); |
| 2553 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2554 | static int add_single_cap_ctl(struct hda_codec *codec, const char *label, |
| 2555 | int idx, bool is_switch, unsigned int ctl) |
| 2556 | { |
| 2557 | struct alc_spec *spec = codec->spec; |
| 2558 | char tmpname[44]; |
| 2559 | int type = is_switch ? ALC_CTL_WIDGET_MUTE : ALC_CTL_WIDGET_VOL; |
| 2560 | const char *sfx = is_switch ? "Switch" : "Volume"; |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2561 | unsigned int chs; |
| 2562 | int err; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2563 | |
| 2564 | if (!ctl) |
| 2565 | return 0; |
| 2566 | |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2567 | if (idx == spec->inv_dmic_split_idx) |
| 2568 | chs = 1; |
| 2569 | else |
| 2570 | chs = 3; |
| 2571 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2572 | if (label) |
| 2573 | snprintf(tmpname, sizeof(tmpname), |
| 2574 | "%s Capture %s", label, sfx); |
| 2575 | else |
| 2576 | snprintf(tmpname, sizeof(tmpname), |
| 2577 | "Capture %s", sfx); |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2578 | err = add_control(spec, type, tmpname, idx, |
| 2579 | amp_val_replace_channels(ctl, chs)); |
| 2580 | if (err < 0 || chs == 3) |
| 2581 | return err; |
| 2582 | |
| 2583 | /* Make independent right kcontrol */ |
| 2584 | if (label) |
| 2585 | snprintf(tmpname, sizeof(tmpname), |
| 2586 | "Inverted %s Capture %s", label, sfx); |
| 2587 | else |
| 2588 | snprintf(tmpname, sizeof(tmpname), |
| 2589 | "Inverted Capture %s", sfx); |
| 2590 | return add_control(spec, type, tmpname, idx, |
| 2591 | amp_val_replace_channels(ctl, 2)); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2592 | } |
| 2593 | |
| 2594 | /* create single (and simple) capture volume and switch controls */ |
| 2595 | static int create_single_cap_vol_ctl(struct hda_codec *codec, int idx, |
| 2596 | unsigned int vol_ctl, unsigned int sw_ctl) |
| 2597 | { |
| 2598 | int err; |
| 2599 | err = add_single_cap_ctl(codec, NULL, idx, false, vol_ctl); |
| 2600 | if (err < 0) |
| 2601 | return err; |
| 2602 | err = add_single_cap_ctl(codec, NULL, idx, true, sw_ctl); |
| 2603 | if (err < 0) |
| 2604 | return err; |
| 2605 | return 0; |
| 2606 | } |
| 2607 | |
| 2608 | /* create bound capture volume and switch controls */ |
| 2609 | static int create_bind_cap_vol_ctl(struct hda_codec *codec, int idx, |
| 2610 | unsigned int vol_ctl, unsigned int sw_ctl) |
| 2611 | { |
| 2612 | struct alc_spec *spec = codec->spec; |
| 2613 | struct snd_kcontrol_new *knew; |
| 2614 | |
| 2615 | if (vol_ctl) { |
| 2616 | knew = alc_kcontrol_new(spec, NULL, &cap_vol_temp); |
| 2617 | if (!knew) |
| 2618 | return -ENOMEM; |
| 2619 | knew->index = idx; |
| 2620 | knew->private_value = vol_ctl; |
| 2621 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2622 | } |
| 2623 | if (sw_ctl) { |
| 2624 | knew = alc_kcontrol_new(spec, NULL, &cap_sw_temp); |
| 2625 | if (!knew) |
| 2626 | return -ENOMEM; |
| 2627 | knew->index = idx; |
| 2628 | knew->private_value = sw_ctl; |
| 2629 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2630 | } |
| 2631 | return 0; |
| 2632 | } |
| 2633 | |
| 2634 | /* return the vol ctl when used first in the imux list */ |
| 2635 | static unsigned int get_first_cap_ctl(struct hda_codec *codec, int idx, int type) |
| 2636 | { |
| 2637 | struct alc_spec *spec = codec->spec; |
| 2638 | struct nid_path *path; |
| 2639 | unsigned int ctl; |
| 2640 | int i; |
| 2641 | |
| 2642 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 2643 | get_adc_nid(codec, 0, idx)); |
| 2644 | if (!path) |
| 2645 | return 0; |
| 2646 | ctl = path->ctls[type]; |
| 2647 | if (!ctl) |
| 2648 | return 0; |
| 2649 | for (i = 0; i < idx - 1; i++) { |
| 2650 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2651 | get_adc_nid(codec, 0, i)); |
| 2652 | if (path && path->ctls[type] == ctl) |
| 2653 | return 0; |
| 2654 | } |
| 2655 | return ctl; |
| 2656 | } |
| 2657 | |
| 2658 | /* create individual capture volume and switch controls per input */ |
| 2659 | static int create_multi_cap_vol_ctl(struct hda_codec *codec) |
| 2660 | { |
| 2661 | struct alc_spec *spec = codec->spec; |
| 2662 | struct hda_input_mux *imux = &spec->input_mux; |
| 2663 | int i, err, type, type_idx = 0; |
| 2664 | const char *prev_label = NULL; |
| 2665 | |
| 2666 | for (i = 0; i < imux->num_items; i++) { |
| 2667 | const char *label; |
| 2668 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, i); |
| 2669 | if (prev_label && !strcmp(label, prev_label)) |
| 2670 | type_idx++; |
| 2671 | else |
| 2672 | type_idx = 0; |
| 2673 | prev_label = label; |
| 2674 | |
| 2675 | for (type = 0; type < 2; type++) { |
| 2676 | err = add_single_cap_ctl(codec, label, type_idx, type, |
| 2677 | get_first_cap_ctl(codec, i, type)); |
| 2678 | if (err < 0) |
| 2679 | return err; |
| 2680 | } |
| 2681 | } |
| 2682 | return 0; |
| 2683 | } |
| 2684 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2685 | static int create_capture_mixers(struct hda_codec *codec) |
| 2686 | { |
| 2687 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2688 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2689 | int i, n, nums, err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2690 | |
| 2691 | if (spec->dyn_adc_switch) |
| 2692 | nums = 1; |
| 2693 | else |
| 2694 | nums = spec->num_adc_nids; |
| 2695 | |
| 2696 | if (!spec->auto_mic && imux->num_items > 1) { |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2697 | struct snd_kcontrol_new *knew; |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 2698 | knew = alc_kcontrol_new(spec, NULL, &cap_src_temp); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2699 | if (!knew) |
| 2700 | return -ENOMEM; |
| 2701 | knew->count = nums; |
| 2702 | } |
| 2703 | |
| 2704 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2705 | bool multi = false; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2706 | int vol, sw; |
| 2707 | |
| 2708 | vol = sw = 0; |
| 2709 | for (i = 0; i < imux->num_items; i++) { |
| 2710 | struct nid_path *path; |
| 2711 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2712 | get_adc_nid(codec, n, i)); |
| 2713 | if (!path) |
| 2714 | continue; |
| 2715 | parse_capvol_in_path(codec, path); |
| 2716 | if (!vol) |
| 2717 | vol = path->ctls[NID_PATH_VOL_CTL]; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2718 | else if (vol != path->ctls[NID_PATH_VOL_CTL]) |
| 2719 | multi = true; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2720 | if (!sw) |
| 2721 | sw = path->ctls[NID_PATH_MUTE_CTL]; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2722 | else if (sw != path->ctls[NID_PATH_MUTE_CTL]) |
| 2723 | multi = true; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2724 | } |
| 2725 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2726 | if (!multi) |
| 2727 | err = create_single_cap_vol_ctl(codec, n, vol, sw); |
| 2728 | else if (!spec->multi_cap_vol) |
| 2729 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); |
| 2730 | else |
| 2731 | err = create_multi_cap_vol_ctl(codec); |
| 2732 | if (err < 0) |
| 2733 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2734 | } |
| 2735 | |
| 2736 | return 0; |
| 2737 | } |
| 2738 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2739 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2740 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2741 | { |
| 2742 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2743 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2744 | hda_nid_t mixer = spec->mixer_nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2745 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2746 | int num_adcs; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2747 | int i, c, err, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2748 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2749 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2750 | num_adcs = alc_auto_fill_adc_nids(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2751 | if (num_adcs < 0) |
| 2752 | return 0; |
| 2753 | |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2754 | spec->inv_dmic_split_idx = -1; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2755 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2756 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2757 | const char *label; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2758 | bool imux_added; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2759 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2760 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2761 | if (!alc_is_input_pin(codec, pin)) |
| 2762 | continue; |
| 2763 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2764 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2765 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2766 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2767 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2768 | type_idx++; |
| 2769 | else |
| 2770 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2771 | prev_label = label; |
| 2772 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2773 | if (mixer) { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2774 | if (is_reachable_path(codec, pin, mixer)) { |
| 2775 | err = new_analog_input(codec, pin, |
| 2776 | label, type_idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2777 | if (err < 0) |
| 2778 | return err; |
| 2779 | } |
| 2780 | } |
| 2781 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2782 | imux_added = false; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2783 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2784 | struct nid_path *path; |
| 2785 | hda_nid_t adc = spec->adc_nids[c]; |
| 2786 | |
| 2787 | if (!is_reachable_path(codec, pin, adc)) |
| 2788 | continue; |
| 2789 | path = snd_array_new(&spec->paths); |
| 2790 | if (!path) |
| 2791 | return -ENOMEM; |
| 2792 | memset(path, 0, sizeof(*path)); |
| 2793 | if (!parse_nid_path(codec, pin, adc, 2, path)) { |
| 2794 | snd_printd(KERN_ERR |
| 2795 | "invalid input path 0x%x -> 0x%x\n", |
| 2796 | pin, adc); |
| 2797 | spec->paths.used--; |
| 2798 | continue; |
| 2799 | } |
| 2800 | |
| 2801 | if (!imux_added) { |
| 2802 | spec->imux_pins[imux->num_items] = pin; |
| 2803 | snd_hda_add_imux_item(imux, label, |
| 2804 | imux->num_items, NULL); |
| 2805 | imux_added = true; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2806 | } |
| 2807 | } |
Takashi Iwai | 81fede89 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2808 | |
| 2809 | if (spec->inv_dmic_split) { |
| 2810 | if (cfg->inputs[i].type == AUTO_PIN_MIC) { |
| 2811 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); |
| 2812 | if (snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT) |
| 2813 | spec->inv_dmic_split_idx = i; |
| 2814 | } |
| 2815 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2816 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2817 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2818 | return 0; |
| 2819 | } |
| 2820 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2821 | /* create a shared input with the headphone out */ |
| 2822 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2823 | { |
| 2824 | struct alc_spec *spec = codec->spec; |
| 2825 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2826 | unsigned int defcfg; |
| 2827 | hda_nid_t nid; |
| 2828 | |
| 2829 | /* only one internal input pin? */ |
| 2830 | if (cfg->num_inputs != 1) |
| 2831 | return 0; |
| 2832 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2833 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2834 | return 0; |
| 2835 | |
| 2836 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2837 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2838 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2839 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2840 | else |
| 2841 | return 0; /* both not available */ |
| 2842 | |
| 2843 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2844 | return 0; /* no input */ |
| 2845 | |
| 2846 | cfg->inputs[1].pin = nid; |
| 2847 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2848 | cfg->num_inputs = 2; |
| 2849 | spec->shared_mic_hp = 1; |
| 2850 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2851 | return 0; |
| 2852 | } |
| 2853 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2854 | static int get_pin_type(int line_out_type) |
| 2855 | { |
| 2856 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2857 | return PIN_HP; |
| 2858 | else |
| 2859 | return PIN_OUT; |
| 2860 | } |
| 2861 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2862 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2863 | { |
| 2864 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2865 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2866 | int i; |
| 2867 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2868 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2869 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6234399 | 2012-12-18 09:06:01 +0100 | [diff] [blame] | 2870 | if (alc_is_input_pin(codec, nid)) |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2871 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2872 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2873 | /* mute loopback inputs */ |
| 2874 | if (spec->mixer_nid) { |
| 2875 | struct nid_path *path; |
| 2876 | path = get_nid_path(codec, nid, spec->mixer_nid); |
| 2877 | if (path) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2878 | activate_path(codec, path, path->active, false); |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2879 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2880 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2881 | } |
| 2882 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2883 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2884 | { |
| 2885 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2886 | int i; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2887 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2888 | for (i = 0; i < spec->paths.used; i++) { |
| 2889 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2890 | if (path->path[0] == nid) |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2891 | return true; |
| 2892 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2893 | return false; |
| 2894 | } |
| 2895 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2896 | /* look for an empty DAC slot */ |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2897 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2898 | bool is_digital) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2899 | { |
| 2900 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2901 | bool cap_digital; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2902 | int i; |
| 2903 | |
| 2904 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2905 | hda_nid_t nid = spec->all_dacs[i]; |
| 2906 | if (!nid || alc_is_dac_already_used(codec, nid)) |
| 2907 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2908 | cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); |
| 2909 | if (is_digital != cap_digital) |
| 2910 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2911 | if (is_reachable_path(codec, nid, pin)) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2912 | return nid; |
| 2913 | } |
| 2914 | return 0; |
| 2915 | } |
| 2916 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2917 | /* called recursively */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2918 | static bool __parse_nid_path(struct hda_codec *codec, |
| 2919 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2920 | int with_aa_mix, struct nid_path *path, int depth) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2921 | { |
| 2922 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2923 | hda_nid_t conn[16]; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2924 | int i, nums; |
| 2925 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2926 | if (to_nid == spec->mixer_nid) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2927 | if (!with_aa_mix) |
| 2928 | return false; |
| 2929 | with_aa_mix = 2; /* mark aa-mix is included */ |
| 2930 | } |
| 2931 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2932 | nums = snd_hda_get_connections(codec, to_nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2933 | for (i = 0; i < nums; i++) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2934 | if (conn[i] != from_nid) { |
| 2935 | /* special case: when from_nid is 0, |
| 2936 | * try to find an empty DAC |
| 2937 | */ |
| 2938 | if (from_nid || |
| 2939 | get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || |
| 2940 | alc_is_dac_already_used(codec, conn[i])) |
| 2941 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2942 | } |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2943 | /* aa-mix is requested but not included? */ |
| 2944 | if (!(spec->mixer_nid && with_aa_mix == 1)) |
| 2945 | goto found; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2946 | } |
| 2947 | if (depth >= MAX_NID_PATH_DEPTH) |
| 2948 | return false; |
| 2949 | for (i = 0; i < nums; i++) { |
| 2950 | unsigned int type; |
| 2951 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2952 | if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN || |
| 2953 | type == AC_WID_PIN) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2954 | continue; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2955 | if (__parse_nid_path(codec, from_nid, conn[i], |
| 2956 | with_aa_mix, path, depth + 1)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2957 | goto found; |
| 2958 | } |
| 2959 | return false; |
| 2960 | |
| 2961 | found: |
| 2962 | path->path[path->depth] = conn[i]; |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2963 | path->idx[path->depth + 1] = i; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2964 | 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] | 2965 | path->multi[path->depth + 1] = 1; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2966 | path->depth++; |
| 2967 | return true; |
| 2968 | } |
| 2969 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2970 | /* parse the widget path from the given nid to the target nid; |
| 2971 | * when @from_nid is 0, try to find an empty DAC; |
| 2972 | * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded. |
| 2973 | * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded. |
| 2974 | * 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] | 2975 | */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2976 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2977 | hda_nid_t to_nid, int with_aa_mix, |
| 2978 | struct nid_path *path) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2979 | { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2980 | if (__parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path, 1)) { |
| 2981 | path->path[path->depth] = to_nid; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2982 | path->depth++; |
| 2983 | #if 0 |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2984 | snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n", |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2985 | path->depth, path->path[0], path->path[1], |
| 2986 | path->path[2], path->path[3], path->path[4]); |
| 2987 | #endif |
| 2988 | return true; |
| 2989 | } |
| 2990 | return false; |
| 2991 | } |
| 2992 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2993 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2994 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2995 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2996 | int i; |
| 2997 | hda_nid_t nid_found = 0; |
| 2998 | |
| 2999 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 3000 | hda_nid_t nid = spec->all_dacs[i]; |
| 3001 | if (!nid || alc_is_dac_already_used(codec, nid)) |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3002 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3003 | if (is_reachable_path(codec, nid, pin)) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3004 | if (nid_found) |
| 3005 | return 0; |
| 3006 | nid_found = nid; |
| 3007 | } |
| 3008 | } |
| 3009 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3010 | } |
| 3011 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3012 | 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] | 3013 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3014 | struct alc_spec *spec = codec->spec; |
| 3015 | int i; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3016 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3017 | for (i = 0; i < spec->paths.used; i++) { |
| 3018 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3019 | if (path->ctls[type] == val) |
| 3020 | return true; |
| 3021 | } |
| 3022 | return false; |
| 3023 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3024 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3025 | /* badness definition */ |
| 3026 | enum { |
| 3027 | /* No primary DAC is found for the main output */ |
| 3028 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3029 | /* No DAC is found for the extra output */ |
| 3030 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3031 | /* No possible multi-ios */ |
| 3032 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3033 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3034 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3035 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3036 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3037 | /* Primary DAC shared with main surrounds */ |
| 3038 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3039 | /* Primary DAC shared with main CLFE */ |
| 3040 | BAD_SHARED_CLFE = 0x10, |
| 3041 | /* Primary DAC shared with extra surrounds */ |
| 3042 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3043 | /* Volume widget is shared */ |
| 3044 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3045 | }; |
| 3046 | |
| 3047 | 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] | 3048 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3049 | 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] | 3050 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3051 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3052 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 3053 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 3054 | int with_aa_mix) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3055 | { |
| 3056 | struct alc_spec *spec = codec->spec; |
| 3057 | struct nid_path *path; |
| 3058 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3059 | if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) |
| 3060 | return NULL; |
| 3061 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3062 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3063 | if (!path) |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3064 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3065 | memset(path, 0, sizeof(*path)); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3066 | if (parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path)) |
| 3067 | return path; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3068 | /* push back */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3069 | spec->paths.used--; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3070 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3071 | } |
| 3072 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3073 | /* get the path between the given NIDs; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3074 | * passing 0 to either @pin or @dac behaves as a wildcard |
| 3075 | */ |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3076 | static struct nid_path * |
| 3077 | 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] | 3078 | { |
| 3079 | struct alc_spec *spec = codec->spec; |
| 3080 | int i; |
| 3081 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3082 | for (i = 0; i < spec->paths.used; i++) { |
| 3083 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3084 | if (path->depth <= 0) |
| 3085 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3086 | if ((!from_nid || path->path[0] == from_nid) && |
| 3087 | (!to_nid || path->path[path->depth - 1] == to_nid)) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3088 | return path; |
| 3089 | } |
| 3090 | return NULL; |
| 3091 | } |
| 3092 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3093 | /* look for widgets in the path between the given NIDs appropriate for |
| 3094 | * volume and mute controls, and assign the values to ctls[]. |
| 3095 | * |
| 3096 | * When no appropriate widget is found in the path, the badness value |
| 3097 | * is incremented depending on the situation. The function returns the |
| 3098 | * total badness for both volume and mute controls. |
| 3099 | */ |
| 3100 | static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, |
| 3101 | hda_nid_t dac) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3102 | { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3103 | struct nid_path *path = get_nid_path(codec, dac, pin); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3104 | hda_nid_t nid; |
| 3105 | unsigned int val; |
| 3106 | int badness = 0; |
| 3107 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3108 | if (!path) |
| 3109 | return BAD_SHARED_VOL * 2; |
| 3110 | nid = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3111 | if (nid) { |
| 3112 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3113 | if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3114 | badness += BAD_SHARED_VOL; |
| 3115 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3116 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3117 | } else |
| 3118 | badness += BAD_SHARED_VOL; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3119 | nid = alc_look_for_out_mute_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3120 | if (nid) { |
| 3121 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3122 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT || |
| 3123 | nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3124 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3125 | else |
| 3126 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3127 | if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3128 | badness += BAD_SHARED_VOL; |
| 3129 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3130 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3131 | } else |
| 3132 | badness += BAD_SHARED_VOL; |
| 3133 | return badness; |
| 3134 | } |
| 3135 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3136 | struct badness_table { |
| 3137 | int no_primary_dac; /* no primary DAC */ |
| 3138 | int no_dac; /* no secondary DACs */ |
| 3139 | int shared_primary; /* primary DAC is shared with main output */ |
| 3140 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3141 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3142 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3143 | }; |
| 3144 | |
| 3145 | static struct badness_table main_out_badness = { |
| 3146 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3147 | .no_dac = BAD_NO_DAC, |
| 3148 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3149 | .shared_surr = BAD_SHARED_SURROUND, |
| 3150 | .shared_clfe = BAD_SHARED_CLFE, |
| 3151 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3152 | }; |
| 3153 | |
| 3154 | static struct badness_table extra_out_badness = { |
| 3155 | .no_primary_dac = BAD_NO_DAC, |
| 3156 | .no_dac = BAD_NO_DAC, |
| 3157 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3158 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3159 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3160 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3161 | }; |
| 3162 | |
| 3163 | /* try to assign DACs to pins and return the resultant badness */ |
| 3164 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3165 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3166 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3167 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3168 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3169 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3170 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3171 | int badness = 0; |
| 3172 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3173 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3174 | if (!num_outs) |
| 3175 | return 0; |
| 3176 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3177 | for (i = 0; i < num_outs; i++) { |
| 3178 | hda_nid_t pin = pins[i]; |
| 3179 | if (!dacs[i]) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 3180 | dacs[i] = alc_auto_look_for_dac(codec, pin, false); |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3181 | if (!dacs[i] && !i) { |
| 3182 | for (j = 1; j < num_outs; j++) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3183 | if (is_reachable_path(codec, dacs[j], pin)) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3184 | dacs[0] = dacs[j]; |
| 3185 | dacs[j] = 0; |
| 3186 | break; |
| 3187 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3188 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3189 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3190 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3191 | if (!dac) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3192 | if (is_reachable_path(codec, dacs[0], pin)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3193 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3194 | else if (cfg->line_outs > i && |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3195 | is_reachable_path(codec, spec->private_dac_nids[i], pin)) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3196 | dac = spec->private_dac_nids[i]; |
| 3197 | if (dac) { |
| 3198 | if (!i) |
| 3199 | badness += bad->shared_primary; |
| 3200 | else if (i == 1) |
| 3201 | badness += bad->shared_surr; |
| 3202 | else |
| 3203 | badness += bad->shared_clfe; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3204 | } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3205 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3206 | badness += bad->shared_surr_main; |
| 3207 | } else if (!i) |
| 3208 | badness += bad->no_primary_dac; |
| 3209 | else |
| 3210 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3211 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3212 | if (!add_new_nid_path(codec, dac, pin, 0)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3213 | dac = dacs[i] = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3214 | if (dac) |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3215 | badness += assign_out_path_ctls(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3216 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3217 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3218 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3219 | } |
| 3220 | |
| 3221 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3222 | hda_nid_t reference_pin, |
| 3223 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3224 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3225 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3226 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3227 | { |
| 3228 | int i; |
| 3229 | bool found = false; |
| 3230 | for (i = 0; i < outs; i++) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3231 | hda_nid_t dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3232 | if (dacs[i]) |
| 3233 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3234 | dac = get_dac_if_single(codec, pins[i]); |
| 3235 | if (!dac) |
| 3236 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3237 | if (add_new_nid_path(codec, dac, pins[i], 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3238 | dacs[i] = dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3239 | found = true; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3240 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3241 | } |
| 3242 | return found; |
| 3243 | } |
| 3244 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3245 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3246 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3247 | bool fill_hardwired, |
| 3248 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3249 | { |
| 3250 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3251 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3252 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3253 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3254 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3255 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3256 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3257 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3258 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3259 | 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] | 3260 | spec->multi_ios = 0; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3261 | snd_array_free(&spec->paths); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3262 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3263 | |
| 3264 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3265 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3266 | bool mapped; |
| 3267 | do { |
| 3268 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3269 | cfg->line_out_pins, |
| 3270 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3271 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3272 | cfg->hp_pins, |
| 3273 | spec->multiout.hp_out_nid); |
| 3274 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3275 | cfg->speaker_pins, |
| 3276 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3277 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3278 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3279 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3280 | if (!err) |
| 3281 | mapped = true; |
| 3282 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3283 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3284 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3285 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3286 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3287 | spec->private_dac_nids, |
| 3288 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3289 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3290 | /* re-count num_dacs and squash invalid entries */ |
| 3291 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3292 | for (i = 0; i < cfg->line_outs; i++) { |
| 3293 | if (spec->private_dac_nids[i]) |
| 3294 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3295 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3296 | memmove(spec->private_dac_nids + i, |
| 3297 | spec->private_dac_nids + i + 1, |
| 3298 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3299 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3300 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3301 | } |
| 3302 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3303 | if (fill_mio_first && |
| 3304 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3305 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3306 | 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] | 3307 | if (err < 0) |
| 3308 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3309 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3310 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3311 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3312 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3313 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3314 | spec->multiout.hp_out_nid, |
| 3315 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3316 | if (err < 0) |
| 3317 | return err; |
| 3318 | badness += err; |
| 3319 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3320 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3321 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3322 | cfg->speaker_pins, |
| 3323 | spec->multiout.extra_out_nid, |
| 3324 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3325 | if (err < 0) |
| 3326 | return err; |
| 3327 | badness += err; |
| 3328 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3329 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3330 | 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] | 3331 | if (err < 0) |
| 3332 | return err; |
| 3333 | badness += err; |
| 3334 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3335 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3336 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3337 | int offset = 0; |
| 3338 | if (cfg->line_outs >= 3) |
| 3339 | offset = 1; |
| 3340 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3341 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3342 | if (err < 0) |
| 3343 | return err; |
| 3344 | badness += err; |
| 3345 | } |
| 3346 | |
| 3347 | if (spec->multi_ios == 2) { |
| 3348 | for (i = 0; i < 2; i++) |
| 3349 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3350 | spec->multi_io[i].dac; |
| 3351 | spec->ext_channel_count = 2; |
| 3352 | } else if (spec->multi_ios) { |
| 3353 | spec->multi_ios = 0; |
| 3354 | badness += BAD_MULTI_IO; |
| 3355 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3356 | |
| 3357 | return badness; |
| 3358 | } |
| 3359 | |
| 3360 | #define DEBUG_BADNESS |
| 3361 | |
| 3362 | #ifdef DEBUG_BADNESS |
| 3363 | #define debug_badness snd_printdd |
| 3364 | #else |
| 3365 | #define debug_badness(...) |
| 3366 | #endif |
| 3367 | |
| 3368 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3369 | { |
| 3370 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3371 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3372 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3373 | spec->multiout.dac_nids[0], |
| 3374 | spec->multiout.dac_nids[1], |
| 3375 | spec->multiout.dac_nids[2], |
| 3376 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3377 | if (spec->multi_ios > 0) |
| 3378 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3379 | spec->multi_ios, |
| 3380 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3381 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3382 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3383 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3384 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3385 | spec->multiout.hp_out_nid[0], |
| 3386 | spec->multiout.hp_out_nid[1], |
| 3387 | spec->multiout.hp_out_nid[2], |
| 3388 | spec->multiout.hp_out_nid[3]); |
| 3389 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3390 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3391 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3392 | spec->multiout.extra_out_nid[0], |
| 3393 | spec->multiout.extra_out_nid[1], |
| 3394 | spec->multiout.extra_out_nid[2], |
| 3395 | spec->multiout.extra_out_nid[3]); |
| 3396 | } |
| 3397 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3398 | /* find all available DACs of the codec */ |
| 3399 | static void alc_fill_all_nids(struct hda_codec *codec) |
| 3400 | { |
| 3401 | struct alc_spec *spec = codec->spec; |
| 3402 | int i; |
| 3403 | hda_nid_t nid = codec->start_nid; |
| 3404 | |
| 3405 | spec->num_all_dacs = 0; |
| 3406 | memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); |
| 3407 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 3408 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) |
| 3409 | continue; |
| 3410 | if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { |
| 3411 | snd_printk(KERN_ERR "hda: Too many DACs!\n"); |
| 3412 | break; |
| 3413 | } |
| 3414 | spec->all_dacs[spec->num_all_dacs++] = nid; |
| 3415 | } |
| 3416 | } |
| 3417 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3418 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3419 | { |
| 3420 | struct alc_spec *spec = codec->spec; |
| 3421 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3422 | struct auto_pin_cfg *best_cfg; |
| 3423 | int best_badness = INT_MAX; |
| 3424 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3425 | bool fill_hardwired = true, fill_mio_first = true; |
| 3426 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3427 | bool hp_spk_swapped = false; |
| 3428 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3429 | alc_fill_all_nids(codec); |
| 3430 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3431 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3432 | if (!best_cfg) |
| 3433 | return -ENOMEM; |
| 3434 | *best_cfg = *cfg; |
| 3435 | |
| 3436 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3437 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3438 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3439 | if (badness < 0) { |
| 3440 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3441 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3442 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3443 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3444 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3445 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3446 | debug_show_configs(spec, cfg); |
| 3447 | if (badness < best_badness) { |
| 3448 | best_badness = badness; |
| 3449 | *best_cfg = *cfg; |
| 3450 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3451 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3452 | } |
| 3453 | if (!badness) |
| 3454 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3455 | fill_mio_first = !fill_mio_first; |
| 3456 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3457 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3458 | fill_hardwired = !fill_hardwired; |
| 3459 | if (!fill_hardwired) |
| 3460 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3461 | if (hp_spk_swapped) |
| 3462 | break; |
| 3463 | hp_spk_swapped = true; |
| 3464 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3465 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3466 | cfg->hp_outs = cfg->line_outs; |
| 3467 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3468 | sizeof(cfg->hp_pins)); |
| 3469 | cfg->line_outs = cfg->speaker_outs; |
| 3470 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3471 | sizeof(cfg->speaker_pins)); |
| 3472 | cfg->speaker_outs = 0; |
| 3473 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3474 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3475 | fill_hardwired = true; |
| 3476 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3477 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3478 | if (cfg->hp_outs > 0 && |
| 3479 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3480 | cfg->speaker_outs = cfg->line_outs; |
| 3481 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3482 | sizeof(cfg->speaker_pins)); |
| 3483 | cfg->line_outs = cfg->hp_outs; |
| 3484 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3485 | sizeof(cfg->hp_pins)); |
| 3486 | cfg->hp_outs = 0; |
| 3487 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3488 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3489 | fill_hardwired = true; |
| 3490 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3491 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3492 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3493 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3494 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3495 | if (badness) { |
| 3496 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3497 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3498 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3499 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3500 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3501 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3502 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3503 | if (cfg->line_out_pins[0]) { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3504 | struct nid_path *path = get_nid_path(codec, |
| 3505 | spec->multiout.dac_nids[0], |
| 3506 | cfg->line_out_pins[0]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3507 | if (path) |
| 3508 | spec->vmaster_nid = alc_look_for_out_vol_nid(codec, path); |
| 3509 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3510 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3511 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3512 | return 0; |
| 3513 | } |
| 3514 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3515 | /* replace the channels in the composed amp value with the given number */ |
| 3516 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) |
| 3517 | { |
| 3518 | val &= ~(0x3U << 16); |
| 3519 | val |= chs << 16; |
| 3520 | return val; |
| 3521 | } |
| 3522 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3523 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3524 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3525 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3526 | struct nid_path *path) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3527 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3528 | unsigned int val; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3529 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3530 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3531 | val = path->ctls[NID_PATH_VOL_CTL]; |
| 3532 | if (!val) |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3533 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3534 | val = amp_val_replace_channels(val, chs); |
| 3535 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, val); |
| 3536 | } |
| 3537 | |
| 3538 | /* return the channel bits suitable for the given path->ctls[] */ |
| 3539 | static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, |
| 3540 | int type) |
| 3541 | { |
| 3542 | int chs = 1; /* mono (left only) */ |
| 3543 | if (path) { |
| 3544 | hda_nid_t nid = get_amp_nid_(path->ctls[type]); |
| 3545 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) |
| 3546 | chs = 3; /* stereo */ |
| 3547 | } |
| 3548 | return chs; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3549 | } |
| 3550 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3551 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3552 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3553 | struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3554 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3555 | int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); |
| 3556 | return alc_auto_add_vol_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3557 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3558 | |
| 3559 | /* create a mute-switch for the given mixer widget; |
| 3560 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3561 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3562 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3563 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3564 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3565 | struct nid_path *path) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3566 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3567 | unsigned int val; |
| 3568 | int type = ALC_CTL_WIDGET_MUTE; |
| 3569 | |
| 3570 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3571 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3572 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 3573 | if (!val) |
| 3574 | return 0; |
| 3575 | val = amp_val_replace_channels(val, chs); |
| 3576 | if (get_amp_direction_(val) == HDA_INPUT) { |
| 3577 | hda_nid_t nid = get_amp_nid_(val); |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3578 | int nums = snd_hda_get_num_conns(codec, nid); |
| 3579 | if (nums > 1) { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3580 | type = ALC_CTL_BIND_MUTE; |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3581 | val |= nums << 19; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3582 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3583 | } |
| 3584 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3585 | } |
| 3586 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3587 | 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] | 3588 | int cidx, struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3589 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3590 | int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); |
| 3591 | return alc_auto_add_sw_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3592 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3593 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3594 | 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] | 3595 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3596 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3597 | int i; |
| 3598 | |
| 3599 | for (i = path->depth - 1; i >= 0; i--) { |
| 3600 | if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) |
| 3601 | return path->path[i]; |
| 3602 | if (i != path->depth - 1 && i != 0 && |
| 3603 | nid_has_mute(codec, path->path[i], HDA_INPUT)) |
| 3604 | return path->path[i]; |
| 3605 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3606 | return 0; |
| 3607 | } |
| 3608 | |
| 3609 | 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] | 3610 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3611 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3612 | int i; |
| 3613 | |
| 3614 | for (i = path->depth - 1; i >= 0; i--) { |
| 3615 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) |
| 3616 | return path->path[i]; |
| 3617 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3618 | return 0; |
| 3619 | } |
| 3620 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3621 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3622 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3623 | const struct auto_pin_cfg *cfg) |
| 3624 | { |
| 3625 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3626 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3627 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3628 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3629 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3630 | noutputs += spec->multi_ios; |
| 3631 | |
| 3632 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3633 | const char *name; |
| 3634 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3635 | hda_nid_t dac, pin; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3636 | struct nid_path *path; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3637 | |
| 3638 | dac = spec->multiout.dac_nids[i]; |
| 3639 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3640 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3641 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3642 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3643 | index = 0; |
| 3644 | name = channel_name[i]; |
| 3645 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3646 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3647 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3648 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3649 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3650 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3651 | if (!path) |
| 3652 | continue; |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3653 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3654 | /* Center/LFE */ |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3655 | err = alc_auto_add_vol_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3656 | if (err < 0) |
| 3657 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3658 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3659 | if (err < 0) |
| 3660 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3661 | err = alc_auto_add_sw_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3662 | if (err < 0) |
| 3663 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3664 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3665 | if (err < 0) |
| 3666 | return err; |
| 3667 | } else { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3668 | err = alc_auto_add_stereo_vol(codec, name, index, 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_stereo_sw(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3672 | if (err < 0) |
| 3673 | return err; |
| 3674 | } |
| 3675 | } |
| 3676 | return 0; |
| 3677 | } |
| 3678 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3679 | 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] | 3680 | hda_nid_t dac, const char *pfx, |
| 3681 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3682 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3683 | struct nid_path *path; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3684 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3685 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3686 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3687 | if (!path) |
| 3688 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3689 | /* bind volume control will be created in the case of dac = 0 */ |
| 3690 | if (dac) { |
| 3691 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, path); |
| 3692 | if (err < 0) |
| 3693 | return err; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3694 | } |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3695 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, path); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3696 | if (err < 0) |
| 3697 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3698 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3699 | } |
| 3700 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3701 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3702 | unsigned int nums, |
| 3703 | struct hda_ctl_ops *ops) |
| 3704 | { |
| 3705 | struct alc_spec *spec = codec->spec; |
| 3706 | struct hda_bind_ctls **ctlp, *ctl; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3707 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3708 | if (!ctlp) |
| 3709 | return NULL; |
| 3710 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3711 | *ctlp = ctl; |
| 3712 | if (ctl) |
| 3713 | ctl->ops = ops; |
| 3714 | return ctl; |
| 3715 | } |
| 3716 | |
| 3717 | /* add playback controls for speaker and HP outputs */ |
| 3718 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3719 | const hda_nid_t *pins, |
| 3720 | const hda_nid_t *dacs, |
| 3721 | const char *pfx) |
| 3722 | { |
| 3723 | struct alc_spec *spec = codec->spec; |
| 3724 | struct hda_bind_ctls *ctl; |
| 3725 | char name[32]; |
| 3726 | int i, n, err; |
| 3727 | |
| 3728 | if (!num_pins || !pins[0]) |
| 3729 | return 0; |
| 3730 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3731 | if (num_pins == 1) { |
| 3732 | hda_nid_t dac = *dacs; |
| 3733 | if (!dac) |
| 3734 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3735 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3736 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3737 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3738 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3739 | hda_nid_t dac; |
| 3740 | if (dacs[num_pins - 1]) |
| 3741 | dac = dacs[i]; /* with individual volumes */ |
| 3742 | else |
| 3743 | dac = 0; |
| 3744 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3745 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3746 | "Bass Speaker", 0); |
| 3747 | } else if (num_pins >= 3) { |
| 3748 | snprintf(name, sizeof(name), "%s %s", |
| 3749 | pfx, channel_name[i]); |
| 3750 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3751 | name, 0); |
| 3752 | } else { |
| 3753 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3754 | pfx, i); |
| 3755 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3756 | if (err < 0) |
| 3757 | return err; |
| 3758 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3759 | if (dacs[num_pins - 1]) |
| 3760 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3761 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3762 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3763 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3764 | if (!ctl) |
| 3765 | return -ENOMEM; |
| 3766 | n = 0; |
| 3767 | for (i = 0; i < num_pins; i++) { |
| 3768 | hda_nid_t vol; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3769 | struct nid_path *path; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3770 | if (!pins[i] || !dacs[i]) |
| 3771 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3772 | path = get_nid_path(codec, dacs[i], pins[i]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3773 | if (!path) |
| 3774 | continue; |
| 3775 | vol = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3776 | if (vol) |
| 3777 | ctl->values[n++] = |
| 3778 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3779 | } |
| 3780 | if (n) { |
| 3781 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3782 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3783 | if (err < 0) |
| 3784 | return err; |
| 3785 | } |
| 3786 | return 0; |
| 3787 | } |
| 3788 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3789 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3790 | { |
| 3791 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3792 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3793 | spec->autocfg.hp_pins, |
| 3794 | spec->multiout.hp_out_nid, |
| 3795 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3796 | } |
| 3797 | |
| 3798 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3799 | { |
| 3800 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3801 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3802 | spec->autocfg.speaker_pins, |
| 3803 | spec->multiout.extra_out_nid, |
| 3804 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3805 | } |
| 3806 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3807 | /* check whether a control with the given (nid, dir, idx) was assigned */ |
| 3808 | static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, |
| 3809 | int dir, int idx) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3810 | { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3811 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3812 | int i, type; |
| 3813 | |
| 3814 | for (i = 0; i < spec->paths.used; i++) { |
| 3815 | struct nid_path *p = snd_array_elem(&spec->paths, i); |
| 3816 | if (p->depth <= 0) |
| 3817 | continue; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 3818 | for (type = 0; type < NID_PATH_NUM_CTLS; type++) { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3819 | unsigned int val = p->ctls[type]; |
| 3820 | if (get_amp_nid_(val) == nid && |
| 3821 | get_amp_direction_(val) == dir && |
| 3822 | get_amp_index_(val) == idx) |
| 3823 | return true; |
| 3824 | } |
| 3825 | } |
| 3826 | return false; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3827 | } |
| 3828 | |
| 3829 | /* can have the amp-in capability? */ |
| 3830 | static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3831 | { |
| 3832 | hda_nid_t nid = path->path[idx]; |
| 3833 | unsigned int caps = get_wcaps(codec, nid); |
| 3834 | unsigned int type = get_wcaps_type(caps); |
| 3835 | |
| 3836 | if (!(caps & AC_WCAP_IN_AMP)) |
| 3837 | return false; |
| 3838 | if (type == AC_WID_PIN && idx > 0) /* only for input pins */ |
| 3839 | return false; |
| 3840 | return true; |
| 3841 | } |
| 3842 | |
| 3843 | /* can have the amp-out capability? */ |
| 3844 | static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3845 | { |
| 3846 | hda_nid_t nid = path->path[idx]; |
| 3847 | unsigned int caps = get_wcaps(codec, nid); |
| 3848 | unsigned int type = get_wcaps_type(caps); |
| 3849 | |
| 3850 | if (!(caps & AC_WCAP_OUT_AMP)) |
| 3851 | return false; |
| 3852 | if (type == AC_WID_PIN && !idx) /* only for output pins */ |
| 3853 | return false; |
| 3854 | return true; |
| 3855 | } |
| 3856 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3857 | /* check whether the given (nid,dir,idx) is active */ |
| 3858 | static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, |
| 3859 | unsigned int idx, unsigned int dir) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3860 | { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3861 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3862 | int i, n; |
| 3863 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3864 | for (n = 0; n < spec->paths.used; n++) { |
| 3865 | struct nid_path *path = snd_array_elem(&spec->paths, n); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3866 | if (!path->active) |
| 3867 | continue; |
| 3868 | for (i = 0; i < path->depth; i++) { |
| 3869 | if (path->path[i] == nid) { |
| 3870 | if (dir == HDA_OUTPUT || path->idx[i] == idx) |
| 3871 | return true; |
| 3872 | break; |
| 3873 | } |
| 3874 | } |
| 3875 | } |
| 3876 | return false; |
| 3877 | } |
| 3878 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3879 | /* get the default amp value for the target state */ |
| 3880 | static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, |
| 3881 | int dir, bool enable) |
| 3882 | { |
| 3883 | unsigned int caps; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3884 | unsigned int val = 0; |
| 3885 | |
| 3886 | caps = query_amp_caps(codec, nid, dir); |
| 3887 | if (caps & AC_AMPCAP_NUM_STEPS) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3888 | /* set to 0dB */ |
| 3889 | if (enable) |
| 3890 | val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3891 | } |
| 3892 | if (caps & AC_AMPCAP_MUTE) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3893 | if (!enable) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3894 | val |= HDA_AMP_MUTE; |
| 3895 | } |
| 3896 | return val; |
| 3897 | } |
| 3898 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3899 | /* initialize the amp value (only at the first time) */ |
| 3900 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
| 3901 | { |
| 3902 | int val = get_amp_val_to_activate(codec, nid, dir, false); |
| 3903 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); |
| 3904 | } |
| 3905 | |
| 3906 | static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 3907 | int idx, bool enable) |
| 3908 | { |
| 3909 | int val; |
| 3910 | if (is_ctl_associated(codec, nid, dir, idx) || |
| 3911 | is_active_nid(codec, nid, dir, idx)) |
| 3912 | return; |
| 3913 | val = get_amp_val_to_activate(codec, nid, dir, enable); |
| 3914 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, 0xff, val); |
| 3915 | } |
| 3916 | |
| 3917 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
| 3918 | int i, bool enable) |
| 3919 | { |
| 3920 | hda_nid_t nid = path->path[i]; |
| 3921 | init_amp(codec, nid, HDA_OUTPUT, 0); |
| 3922 | activate_amp(codec, nid, HDA_OUTPUT, 0, enable); |
| 3923 | } |
| 3924 | |
| 3925 | static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3926 | int i, bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3927 | { |
| 3928 | struct alc_spec *spec = codec->spec; |
| 3929 | hda_nid_t conn[16]; |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3930 | int n, nums, idx; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3931 | int type; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3932 | hda_nid_t nid = path->path[i]; |
| 3933 | |
| 3934 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3935 | type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3936 | if (type == AC_WID_PIN || |
| 3937 | (type == AC_WID_AUD_IN && codec->single_adc_amp)) { |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3938 | nums = 1; |
| 3939 | idx = 0; |
| 3940 | } else |
| 3941 | idx = path->idx[i]; |
| 3942 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3943 | for (n = 0; n < nums; n++) |
| 3944 | init_amp(codec, nid, HDA_INPUT, n); |
| 3945 | |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3946 | if (is_ctl_associated(codec, nid, HDA_INPUT, idx)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3947 | return; |
| 3948 | |
| 3949 | /* here is a little bit tricky in comparison with activate_amp_out(); |
| 3950 | * when aa-mixer is available, we need to enable the path as well |
| 3951 | */ |
| 3952 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3953 | if (n != idx && (!add_aamix || conn[n] != spec->mixer_nid)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3954 | continue; |
| 3955 | activate_amp(codec, nid, HDA_INPUT, n, enable); |
| 3956 | } |
| 3957 | } |
| 3958 | |
| 3959 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3960 | bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3961 | { |
| 3962 | int i; |
| 3963 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3964 | if (!enable) |
| 3965 | path->active = false; |
| 3966 | |
| 3967 | for (i = path->depth - 1; i >= 0; i--) { |
Takashi Iwai | 183a444 | 2012-12-17 18:00:02 +0100 | [diff] [blame] | 3968 | if (enable && path->multi[i]) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3969 | snd_hda_codec_write_cache(codec, path->path[i], 0, |
| 3970 | AC_VERB_SET_CONNECT_SEL, |
| 3971 | path->idx[i]); |
| 3972 | if (has_amp_in(codec, path, i)) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3973 | activate_amp_in(codec, path, i, enable, add_aamix); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3974 | if (has_amp_out(codec, path, i)) |
| 3975 | activate_amp_out(codec, path, i, enable); |
| 3976 | } |
| 3977 | |
| 3978 | if (enable) |
| 3979 | path->active = true; |
| 3980 | } |
| 3981 | |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3982 | /* configure the path from the given dac to the pin as the proper output */ |
| 3983 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3984 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3985 | hda_nid_t dac) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3986 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3987 | struct nid_path *path; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3988 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3989 | snd_hda_set_pin_ctl_cache(codec, pin, pin_type); |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3990 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3991 | if (!path) |
| 3992 | return; |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 3993 | if (path->active) |
| 3994 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3995 | activate_path(codec, path, true, true); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3996 | } |
| 3997 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3998 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3999 | { |
| 4000 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 4001 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4002 | int i; |
| 4003 | |
| 4004 | for (i = 0; i <= HDA_SIDE; i++) { |
| 4005 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4006 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4007 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4008 | spec->multiout.dac_nids[i]); |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 4009 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4010 | } |
| 4011 | } |
| 4012 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4013 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4014 | { |
| 4015 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4016 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4017 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4018 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 4019 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4020 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 4021 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 4022 | pin = spec->autocfg.hp_pins[i]; |
| 4023 | if (!pin) |
| 4024 | break; |
| 4025 | dac = spec->multiout.hp_out_nid[i]; |
| 4026 | if (!dac) { |
| 4027 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 4028 | dac = spec->multiout.hp_out_nid[0]; |
| 4029 | else |
| 4030 | dac = spec->multiout.dac_nids[0]; |
| 4031 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4032 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4033 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4034 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4035 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4036 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4037 | pin = spec->autocfg.speaker_pins[i]; |
| 4038 | if (!pin) |
| 4039 | break; |
| 4040 | dac = spec->multiout.extra_out_nid[i]; |
| 4041 | if (!dac) { |
| 4042 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 4043 | dac = spec->multiout.extra_out_nid[0]; |
| 4044 | else |
| 4045 | dac = spec->multiout.dac_nids[0]; |
| 4046 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4047 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4048 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4049 | } |
| 4050 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4051 | /* check whether the given pin can be a multi-io pin */ |
| 4052 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 4053 | unsigned int location, hda_nid_t nid) |
| 4054 | { |
| 4055 | unsigned int defcfg, caps; |
| 4056 | |
| 4057 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 4058 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 4059 | return false; |
| 4060 | if (location && get_defcfg_location(defcfg) != location) |
| 4061 | return false; |
| 4062 | caps = snd_hda_query_pin_caps(codec, nid); |
| 4063 | if (!(caps & AC_PINCAP_OUT)) |
| 4064 | return false; |
| 4065 | return true; |
| 4066 | } |
| 4067 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4068 | /* |
| 4069 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4070 | * |
| 4071 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 4072 | * zero if any pins are filled, non-zero if nothing found. |
| 4073 | * When hardwired is off, try to fill possible input pins, and returns |
| 4074 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4075 | */ |
| 4076 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4077 | hda_nid_t reference_pin, |
| 4078 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4079 | { |
| 4080 | struct alc_spec *spec = codec->spec; |
| 4081 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4082 | int type, i, j, dacs, num_pins, old_pins; |
| 4083 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 4084 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4085 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4086 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4087 | old_pins = spec->multi_ios; |
| 4088 | if (old_pins >= 2) |
| 4089 | goto end_fill; |
| 4090 | |
| 4091 | num_pins = 0; |
| 4092 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4093 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4094 | if (cfg->inputs[i].type != type) |
| 4095 | continue; |
| 4096 | if (can_be_multiio_pin(codec, location, |
| 4097 | cfg->inputs[i].pin)) |
| 4098 | num_pins++; |
| 4099 | } |
| 4100 | } |
| 4101 | if (num_pins < 2) |
| 4102 | goto end_fill; |
| 4103 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4104 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4105 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4106 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4107 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4108 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4109 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4110 | if (cfg->inputs[i].type != type) |
| 4111 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4112 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4113 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4114 | for (j = 0; j < spec->multi_ios; j++) { |
| 4115 | if (nid == spec->multi_io[j].pin) |
| 4116 | break; |
| 4117 | } |
| 4118 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4119 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4120 | |
| 4121 | if (offset && offset + spec->multi_ios < dacs) { |
| 4122 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 4123 | if (!is_reachable_path(codec, dac, nid)) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4124 | dac = 0; |
| 4125 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4126 | if (hardwired) |
| 4127 | dac = get_dac_if_single(codec, nid); |
| 4128 | else if (!dac) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 4129 | dac = alc_auto_look_for_dac(codec, nid, false); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4130 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4131 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4132 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4133 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 4134 | if (!add_new_nid_path(codec, dac, nid, 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4135 | badness++; |
| 4136 | continue; |
| 4137 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4138 | spec->multi_io[spec->multi_ios].pin = nid; |
| 4139 | spec->multi_io[spec->multi_ios].dac = dac; |
| 4140 | spec->multi_ios++; |
| 4141 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4142 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4143 | } |
| 4144 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4145 | end_fill: |
| 4146 | if (badness) |
| 4147 | badness = BAD_MULTI_IO; |
| 4148 | if (old_pins == spec->multi_ios) { |
| 4149 | if (hardwired) |
| 4150 | return 1; /* nothing found */ |
| 4151 | else |
| 4152 | return badness; /* no badness if nothing found */ |
| 4153 | } |
| 4154 | if (!hardwired && spec->multi_ios < 2) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4155 | /* cancel newly assigned paths */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4156 | spec->paths.used -= spec->multi_ios - old_pins; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4157 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4158 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4159 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4160 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 4161 | /* assign volume and mute controls */ |
| 4162 | for (i = old_pins; i < spec->multi_ios; i++) |
| 4163 | badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, |
| 4164 | spec->multi_io[i].dac); |
| 4165 | |
| 4166 | return badness; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4167 | } |
| 4168 | |
| 4169 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 4170 | struct snd_ctl_elem_info *uinfo) |
| 4171 | { |
| 4172 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4173 | struct alc_spec *spec = codec->spec; |
| 4174 | |
| 4175 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 4176 | uinfo->count = 1; |
| 4177 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 4178 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 4179 | uinfo->value.enumerated.item = spec->multi_ios; |
| 4180 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 4181 | (uinfo->value.enumerated.item + 1) * 2); |
| 4182 | return 0; |
| 4183 | } |
| 4184 | |
| 4185 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 4186 | struct snd_ctl_elem_value *ucontrol) |
| 4187 | { |
| 4188 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4189 | struct alc_spec *spec = codec->spec; |
| 4190 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 4191 | return 0; |
| 4192 | } |
| 4193 | |
| 4194 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 4195 | { |
| 4196 | struct alc_spec *spec = codec->spec; |
| 4197 | hda_nid_t nid = spec->multi_io[idx].pin; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4198 | struct nid_path *path; |
| 4199 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 4200 | path = get_nid_path(codec, spec->multi_io[idx].dac, nid); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4201 | if (!path) |
| 4202 | return -EINVAL; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4203 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4204 | if (path->active == output) |
| 4205 | return 0; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4206 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4207 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4208 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4209 | activate_path(codec, path, true, true); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4210 | } else { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4211 | activate_path(codec, path, false, true); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4212 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4213 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4214 | } |
| 4215 | return 0; |
| 4216 | } |
| 4217 | |
| 4218 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4219 | struct snd_ctl_elem_value *ucontrol) |
| 4220 | { |
| 4221 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4222 | struct alc_spec *spec = codec->spec; |
| 4223 | int i, ch; |
| 4224 | |
| 4225 | ch = ucontrol->value.enumerated.item[0]; |
| 4226 | if (ch < 0 || ch > spec->multi_ios) |
| 4227 | return -EINVAL; |
| 4228 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4229 | return 0; |
| 4230 | spec->ext_channel_count = (ch + 1) * 2; |
| 4231 | for (i = 0; i < spec->multi_ios; i++) |
| 4232 | alc_set_multi_io(codec, i, i < ch); |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4233 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4234 | spec->const_channel_count); |
| 4235 | if (spec->need_dac_fix) |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4236 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4237 | return 1; |
| 4238 | } |
| 4239 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4240 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4241 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4242 | .name = "Channel Mode", |
| 4243 | .info = alc_auto_ch_mode_info, |
| 4244 | .get = alc_auto_ch_mode_get, |
| 4245 | .put = alc_auto_ch_mode_put, |
| 4246 | }; |
| 4247 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4248 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4249 | { |
| 4250 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4251 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4252 | if (spec->multi_ios > 0) { |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 4253 | if (!alc_kcontrol_new(spec, NULL, &alc_auto_channel_mode_enum)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4254 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4255 | } |
| 4256 | return 0; |
| 4257 | } |
| 4258 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4259 | static void alc_auto_init_multi_io(struct hda_codec *codec) |
| 4260 | { |
| 4261 | struct alc_spec *spec = codec->spec; |
| 4262 | int i; |
| 4263 | |
| 4264 | for (i = 0; i < spec->multi_ios; i++) { |
| 4265 | hda_nid_t pin = spec->multi_io[i].pin; |
| 4266 | struct nid_path *path; |
| 4267 | path = get_nid_path(codec, spec->multi_io[i].dac, pin); |
| 4268 | if (!path) |
| 4269 | continue; |
| 4270 | if (!spec->multi_io[i].ctl_in) |
| 4271 | spec->multi_io[i].ctl_in = |
| 4272 | snd_hda_codec_update_cache(codec, pin, 0, |
| 4273 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4274 | activate_path(codec, path, path->active, true); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4275 | } |
| 4276 | } |
| 4277 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4278 | /* |
| 4279 | * initialize ADC paths |
| 4280 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4281 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4282 | { |
| 4283 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 4284 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4285 | struct nid_path *path; |
| 4286 | int i, c, nums; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4287 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4288 | if (spec->dyn_adc_switch) |
| 4289 | nums = 1; |
| 4290 | else |
| 4291 | nums = spec->num_adc_nids; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4292 | |
| 4293 | for (c = 0; c < nums; c++) { |
| 4294 | for (i = 0; i < imux->num_items; i++) { |
| 4295 | path = get_nid_path(codec, spec->imux_pins[i], |
| 4296 | get_adc_nid(codec, c, i)); |
| 4297 | if (path) { |
| 4298 | bool active = path->active; |
| 4299 | if (i == spec->cur_mux[c]) |
| 4300 | active = true; |
| 4301 | activate_path(codec, path, active, false); |
| 4302 | } |
| 4303 | } |
| 4304 | } |
| 4305 | |
| 4306 | alc_inv_dmic_sync(codec, true); |
| 4307 | if (spec->shared_mic_hp) |
| 4308 | update_shared_mic_hp(codec, spec->cur_mux[0]); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4309 | } |
| 4310 | |
| 4311 | /* add mic boosts if needed */ |
| 4312 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4313 | { |
| 4314 | struct alc_spec *spec = codec->spec; |
| 4315 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4316 | int i, err; |
| 4317 | int type_idx = 0; |
| 4318 | hda_nid_t nid; |
| 4319 | const char *prev_label = NULL; |
| 4320 | |
| 4321 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4322 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4323 | break; |
| 4324 | nid = cfg->inputs[i].pin; |
| 4325 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4326 | const char *label; |
| 4327 | char boost_label[32]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4328 | struct nid_path *path; |
| 4329 | unsigned int val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4330 | |
| 4331 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4332 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4333 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4334 | if (prev_label && !strcmp(label, prev_label)) |
| 4335 | type_idx++; |
| 4336 | else |
| 4337 | type_idx = 0; |
| 4338 | prev_label = label; |
| 4339 | |
| 4340 | snprintf(boost_label, sizeof(boost_label), |
| 4341 | "%s Boost Volume", label); |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4342 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4343 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4344 | boost_label, type_idx, val); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4345 | if (err < 0) |
| 4346 | return err; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4347 | |
| 4348 | path = get_nid_path(codec, nid, 0); |
| 4349 | if (path) |
| 4350 | path->ctls[NID_PATH_BOOST_CTL] = val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4351 | } |
| 4352 | } |
| 4353 | return 0; |
| 4354 | } |
| 4355 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4356 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4357 | * standard auto-parser initializations |
| 4358 | */ |
| 4359 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4360 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4361 | alc_auto_init_multi_out(codec); |
| 4362 | alc_auto_init_extra_out(codec); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4363 | alc_auto_init_multi_io(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4364 | alc_auto_init_analog_input(codec); |
| 4365 | alc_auto_init_input_src(codec); |
| 4366 | alc_auto_init_digital(codec); |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 4367 | /* call init functions of standard auto-mute helpers */ |
| 4368 | alc_hp_automute(codec, NULL); |
| 4369 | alc_line_automute(codec, NULL); |
| 4370 | alc_mic_automute(codec, NULL); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4371 | } |
| 4372 | |
| 4373 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4374 | * Digital-beep handlers |
| 4375 | */ |
| 4376 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4377 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4378 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4379 | |
| 4380 | static const struct snd_pci_quirk beep_white_list[] = { |
Duncan Roe | 7110005 | 2012-10-10 14:19:50 +0200 | [diff] [blame] | 4381 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4382 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4383 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4384 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4385 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4386 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4387 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4388 | {} |
| 4389 | }; |
| 4390 | |
| 4391 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4392 | { |
| 4393 | struct alc_spec *spec = codec->spec; |
| 4394 | const struct snd_pci_quirk *q; |
| 4395 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4396 | if (q) |
| 4397 | return q->value; |
| 4398 | return spec->cdefine.enable_pcbeep; |
| 4399 | } |
| 4400 | #else |
| 4401 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4402 | #define has_cdefine_beep(codec) 0 |
| 4403 | #endif |
| 4404 | |
| 4405 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4406 | /* return 1 if successful, 0 if the proper config is not found, |
| 4407 | * or a negative error code |
| 4408 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4409 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4410 | const hda_nid_t *ignore_nids, |
| 4411 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4412 | { |
| 4413 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4414 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4415 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4416 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4417 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4418 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4419 | if (err < 0) |
| 4420 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4421 | if (!cfg->line_outs) { |
| 4422 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4423 | spec->multiout.max_channels = 2; |
| 4424 | spec->no_analog = 1; |
| 4425 | goto dig_only; |
| 4426 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4427 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4428 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4429 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4430 | if (!spec->no_primary_hp && |
| 4431 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4432 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4433 | /* use HP as primary out */ |
| 4434 | cfg->speaker_outs = cfg->line_outs; |
| 4435 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4436 | sizeof(cfg->speaker_pins)); |
| 4437 | cfg->line_outs = cfg->hp_outs; |
| 4438 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4439 | cfg->hp_outs = 0; |
| 4440 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4441 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4442 | } |
| 4443 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4444 | err = alc_auto_fill_dac_nids(codec); |
| 4445 | if (err < 0) |
| 4446 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4447 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4448 | if (err < 0) |
| 4449 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4450 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4451 | if (err < 0) |
| 4452 | return err; |
| 4453 | err = alc_auto_create_hp_out(codec); |
| 4454 | if (err < 0) |
| 4455 | return err; |
| 4456 | err = alc_auto_create_speaker_out(codec); |
| 4457 | if (err < 0) |
| 4458 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4459 | err = alc_auto_create_shared_input(codec); |
| 4460 | if (err < 0) |
| 4461 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4462 | err = alc_auto_create_input_ctls(codec); |
| 4463 | if (err < 0) |
| 4464 | return err; |
| 4465 | |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4466 | /* check the multiple speaker pins */ |
| 4467 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4468 | spec->const_channel_count = cfg->line_outs * 2; |
| 4469 | else |
| 4470 | spec->const_channel_count = cfg->speaker_outs * 2; |
| 4471 | |
| 4472 | if (spec->multi_ios > 0) |
| 4473 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4474 | spec->const_channel_count); |
| 4475 | else |
| 4476 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4477 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4478 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4479 | alc_auto_parse_digital(codec); |
| 4480 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4481 | if (ssid_nids) |
| 4482 | alc_ssid_check(codec, ssid_nids); |
| 4483 | |
| 4484 | if (!spec->no_analog) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4485 | err = alc_init_automute(codec); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 4486 | if (err < 0) |
| 4487 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4488 | |
| 4489 | err = check_dyn_adc_switch(codec); |
| 4490 | if (err < 0) |
| 4491 | return err; |
| 4492 | |
| 4493 | if (!spec->shared_mic_hp) { |
| 4494 | err = alc_init_auto_mic(codec); |
| 4495 | if (err < 0) |
| 4496 | return err; |
| 4497 | } |
| 4498 | |
| 4499 | err = create_capture_mixers(codec); |
| 4500 | if (err < 0) |
| 4501 | return err; |
| 4502 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4503 | err = alc_auto_add_mic_boost(codec); |
| 4504 | if (err < 0) |
| 4505 | return err; |
| 4506 | } |
| 4507 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4508 | if (spec->kctls.list) |
| 4509 | add_mixer(spec, spec->kctls.list); |
| 4510 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4511 | return 1; |
| 4512 | } |
| 4513 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4514 | /* common preparation job for alc_spec */ |
| 4515 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4516 | { |
| 4517 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4518 | int err; |
| 4519 | |
| 4520 | if (!spec) |
| 4521 | return -ENOMEM; |
| 4522 | codec->spec = spec; |
Takashi Iwai | 1098b7c | 2012-12-17 20:03:15 +0100 | [diff] [blame] | 4523 | codec->single_adc_amp = 1; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4524 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 4525 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 4526 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4527 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4528 | |
| 4529 | err = alc_codec_rename_from_preset(codec); |
| 4530 | if (err < 0) { |
| 4531 | kfree(spec); |
| 4532 | return err; |
| 4533 | } |
| 4534 | return 0; |
| 4535 | } |
| 4536 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4537 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4538 | { |
| 4539 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4540 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4541 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4542 | } |
| 4543 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4544 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4545 | * ALC880 fix-ups |
| 4546 | */ |
| 4547 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4548 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4549 | ALC880_FIXUP_GPIO2, |
| 4550 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4551 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4552 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4553 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4554 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4555 | ALC880_FIXUP_VOL_KNOB, |
| 4556 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4557 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4558 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4559 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4560 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4561 | ALC880_FIXUP_3ST_BASE, |
| 4562 | ALC880_FIXUP_3ST, |
| 4563 | ALC880_FIXUP_3ST_DIG, |
| 4564 | ALC880_FIXUP_5ST_BASE, |
| 4565 | ALC880_FIXUP_5ST, |
| 4566 | ALC880_FIXUP_5ST_DIG, |
| 4567 | ALC880_FIXUP_6ST_BASE, |
| 4568 | ALC880_FIXUP_6ST, |
| 4569 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4570 | }; |
| 4571 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4572 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4573 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4574 | const struct alc_fixup *fix, int action) |
| 4575 | { |
| 4576 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4577 | 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] | 4578 | } |
| 4579 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4580 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4581 | [ALC880_FIXUP_GPIO1] = { |
| 4582 | .type = ALC_FIXUP_VERBS, |
| 4583 | .v.verbs = alc_gpio1_init_verbs, |
| 4584 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4585 | [ALC880_FIXUP_GPIO2] = { |
| 4586 | .type = ALC_FIXUP_VERBS, |
| 4587 | .v.verbs = alc_gpio2_init_verbs, |
| 4588 | }, |
| 4589 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4590 | .type = ALC_FIXUP_VERBS, |
| 4591 | .v.verbs = (const struct hda_verb[]) { |
| 4592 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4593 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4594 | { } |
| 4595 | }, |
| 4596 | .chained = true, |
| 4597 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4598 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4599 | [ALC880_FIXUP_LG] = { |
| 4600 | .type = ALC_FIXUP_PINS, |
| 4601 | .v.pins = (const struct alc_pincfg[]) { |
| 4602 | /* disable bogus unused pins */ |
| 4603 | { 0x16, 0x411111f0 }, |
| 4604 | { 0x18, 0x411111f0 }, |
| 4605 | { 0x1a, 0x411111f0 }, |
| 4606 | { } |
| 4607 | } |
| 4608 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4609 | [ALC880_FIXUP_W810] = { |
| 4610 | .type = ALC_FIXUP_PINS, |
| 4611 | .v.pins = (const struct alc_pincfg[]) { |
| 4612 | /* disable bogus unused pins */ |
| 4613 | { 0x17, 0x411111f0 }, |
| 4614 | { } |
| 4615 | }, |
| 4616 | .chained = true, |
| 4617 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4618 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4619 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4620 | .type = ALC_FIXUP_VERBS, |
| 4621 | .v.verbs = (const struct hda_verb[]) { |
| 4622 | /* change to EAPD mode */ |
| 4623 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4624 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4625 | {} |
| 4626 | }, |
| 4627 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4628 | [ALC880_FIXUP_TCL_S700] = { |
| 4629 | .type = ALC_FIXUP_VERBS, |
| 4630 | .v.verbs = (const struct hda_verb[]) { |
| 4631 | /* change to EAPD mode */ |
| 4632 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4633 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4634 | {} |
| 4635 | }, |
| 4636 | .chained = true, |
| 4637 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4638 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4639 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4640 | .type = ALC_FIXUP_FUNC, |
| 4641 | .v.func = alc880_fixup_vol_knob, |
| 4642 | }, |
| 4643 | [ALC880_FIXUP_FUJITSU] = { |
| 4644 | /* override all pins as BIOS on old Amilo is broken */ |
| 4645 | .type = ALC_FIXUP_PINS, |
| 4646 | .v.pins = (const struct alc_pincfg[]) { |
| 4647 | { 0x14, 0x0121411f }, /* HP */ |
| 4648 | { 0x15, 0x99030120 }, /* speaker */ |
| 4649 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4650 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4651 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4652 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4653 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4654 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4655 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4656 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4657 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4658 | { } |
| 4659 | }, |
| 4660 | .chained = true, |
| 4661 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4662 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4663 | [ALC880_FIXUP_F1734] = { |
| 4664 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4665 | .type = ALC_FIXUP_PINS, |
| 4666 | .v.pins = (const struct alc_pincfg[]) { |
| 4667 | { 0x14, 0x0121411f }, /* HP */ |
| 4668 | { 0x15, 0x99030120 }, /* speaker */ |
| 4669 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4670 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4671 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4672 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4673 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4674 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4675 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4676 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4677 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4678 | { } |
| 4679 | }, |
| 4680 | .chained = true, |
| 4681 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4682 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4683 | [ALC880_FIXUP_UNIWILL] = { |
| 4684 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4685 | .type = ALC_FIXUP_PINS, |
| 4686 | .v.pins = (const struct alc_pincfg[]) { |
| 4687 | { 0x14, 0x0121411f }, /* HP */ |
| 4688 | { 0x15, 0x99030120 }, /* speaker */ |
| 4689 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4690 | { } |
| 4691 | }, |
| 4692 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4693 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4694 | .type = ALC_FIXUP_PINS, |
| 4695 | .v.pins = (const struct alc_pincfg[]) { |
| 4696 | /* disable bogus unused pins */ |
| 4697 | { 0x17, 0x411111f0 }, |
| 4698 | { 0x19, 0x411111f0 }, |
| 4699 | { 0x1b, 0x411111f0 }, |
| 4700 | { 0x1f, 0x411111f0 }, |
| 4701 | { } |
| 4702 | } |
| 4703 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4704 | [ALC880_FIXUP_Z71V] = { |
| 4705 | .type = ALC_FIXUP_PINS, |
| 4706 | .v.pins = (const struct alc_pincfg[]) { |
| 4707 | /* set up the whole pins as BIOS is utterly broken */ |
| 4708 | { 0x14, 0x99030120 }, /* speaker */ |
| 4709 | { 0x15, 0x0121411f }, /* HP */ |
| 4710 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4711 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4712 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4713 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4714 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4715 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4716 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4717 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4718 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4719 | { } |
| 4720 | } |
| 4721 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4722 | [ALC880_FIXUP_3ST_BASE] = { |
| 4723 | .type = ALC_FIXUP_PINS, |
| 4724 | .v.pins = (const struct alc_pincfg[]) { |
| 4725 | { 0x14, 0x01014010 }, /* line-out */ |
| 4726 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4727 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4728 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4729 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4730 | { 0x19, 0x0121411f }, /* HP */ |
| 4731 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4732 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4733 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4734 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4735 | /* 0x1e is filled in below */ |
| 4736 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4737 | { } |
| 4738 | } |
| 4739 | }, |
| 4740 | [ALC880_FIXUP_3ST] = { |
| 4741 | .type = ALC_FIXUP_PINS, |
| 4742 | .v.pins = (const struct alc_pincfg[]) { |
| 4743 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4744 | { } |
| 4745 | }, |
| 4746 | .chained = true, |
| 4747 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4748 | }, |
| 4749 | [ALC880_FIXUP_3ST_DIG] = { |
| 4750 | .type = ALC_FIXUP_PINS, |
| 4751 | .v.pins = (const struct alc_pincfg[]) { |
| 4752 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4753 | { } |
| 4754 | }, |
| 4755 | .chained = true, |
| 4756 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4757 | }, |
| 4758 | [ALC880_FIXUP_5ST_BASE] = { |
| 4759 | .type = ALC_FIXUP_PINS, |
| 4760 | .v.pins = (const struct alc_pincfg[]) { |
| 4761 | { 0x14, 0x01014010 }, /* front */ |
| 4762 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4763 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4764 | { 0x17, 0x01016412 }, /* surr */ |
| 4765 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4766 | { 0x19, 0x0121411f }, /* HP */ |
| 4767 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4768 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4769 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4770 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4771 | /* 0x1e is filled in below */ |
| 4772 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4773 | { } |
| 4774 | } |
| 4775 | }, |
| 4776 | [ALC880_FIXUP_5ST] = { |
| 4777 | .type = ALC_FIXUP_PINS, |
| 4778 | .v.pins = (const struct alc_pincfg[]) { |
| 4779 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4780 | { } |
| 4781 | }, |
| 4782 | .chained = true, |
| 4783 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4784 | }, |
| 4785 | [ALC880_FIXUP_5ST_DIG] = { |
| 4786 | .type = ALC_FIXUP_PINS, |
| 4787 | .v.pins = (const struct alc_pincfg[]) { |
| 4788 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4789 | { } |
| 4790 | }, |
| 4791 | .chained = true, |
| 4792 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4793 | }, |
| 4794 | [ALC880_FIXUP_6ST_BASE] = { |
| 4795 | .type = ALC_FIXUP_PINS, |
| 4796 | .v.pins = (const struct alc_pincfg[]) { |
| 4797 | { 0x14, 0x01014010 }, /* front */ |
| 4798 | { 0x15, 0x01016412 }, /* surr */ |
| 4799 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4800 | { 0x17, 0x01012414 }, /* side */ |
| 4801 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4802 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4803 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4804 | { 0x1b, 0x0121411f }, /* HP */ |
| 4805 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4806 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4807 | /* 0x1e is filled in below */ |
| 4808 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4809 | { } |
| 4810 | } |
| 4811 | }, |
| 4812 | [ALC880_FIXUP_6ST] = { |
| 4813 | .type = ALC_FIXUP_PINS, |
| 4814 | .v.pins = (const struct alc_pincfg[]) { |
| 4815 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4816 | { } |
| 4817 | }, |
| 4818 | .chained = true, |
| 4819 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4820 | }, |
| 4821 | [ALC880_FIXUP_6ST_DIG] = { |
| 4822 | .type = ALC_FIXUP_PINS, |
| 4823 | .v.pins = (const struct alc_pincfg[]) { |
| 4824 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4825 | { } |
| 4826 | }, |
| 4827 | .chained = true, |
| 4828 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4829 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4830 | }; |
| 4831 | |
| 4832 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4833 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4834 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4835 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4836 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4837 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4838 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4839 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4840 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4841 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4842 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4843 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4844 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4845 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4846 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4847 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4848 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4849 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4850 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4851 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4852 | |
| 4853 | /* Below is the copied entries from alc880_quirks.c. |
| 4854 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4855 | * on these machines, thus they are kept to be compatible with |
| 4856 | * the old static quirks. Once when it's confirmed to work without |
| 4857 | * these overrides, it'd be better to remove. |
| 4858 | */ |
| 4859 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4860 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4861 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4862 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4863 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4864 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4865 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4866 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4867 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4868 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4869 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4870 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4871 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4872 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4873 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4874 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4875 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4876 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4877 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4878 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4879 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4880 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4881 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4882 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4883 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4884 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4885 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4886 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4887 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4888 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4889 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4890 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4891 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4892 | /* default Intel */ |
| 4893 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4894 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4895 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4896 | {} |
| 4897 | }; |
| 4898 | |
| 4899 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4900 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4901 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4902 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4903 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4904 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4905 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4906 | {} |
| 4907 | }; |
| 4908 | |
| 4909 | |
| 4910 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4911 | * OK, here we have finally the patch for ALC880 |
| 4912 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4913 | static int patch_alc880(struct hda_codec *codec) |
| 4914 | { |
| 4915 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4916 | int err; |
| 4917 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4918 | err = alc_alloc_spec(codec, 0x0b); |
| 4919 | if (err < 0) |
| 4920 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4921 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4922 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4923 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4924 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4925 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4926 | alc880_fixups); |
| 4927 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4928 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4929 | /* automatic parse from the BIOS config */ |
| 4930 | err = alc880_parse_auto_config(codec); |
| 4931 | if (err < 0) |
| 4932 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4933 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4934 | if (!spec->no_analog) { |
| 4935 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4936 | if (err < 0) |
| 4937 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4938 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4939 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4940 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4941 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4942 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 4943 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4944 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4945 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4946 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4947 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4948 | |
| 4949 | error: |
| 4950 | alc_free(codec); |
| 4951 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4952 | } |
| 4953 | |
| 4954 | |
| 4955 | /* |
| 4956 | * ALC260 support |
| 4957 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4958 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4959 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4960 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4961 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4962 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4963 | } |
| 4964 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4965 | /* |
| 4966 | * Pin config fixes |
| 4967 | */ |
| 4968 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4969 | ALC260_FIXUP_HP_DC5750, |
| 4970 | ALC260_FIXUP_HP_PIN_0F, |
| 4971 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4972 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4973 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4974 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4975 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4976 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4977 | }; |
| 4978 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4979 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4980 | { |
| 4981 | struct alc_spec *spec = codec->spec; |
| 4982 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4983 | spec->hp_jack_present); |
| 4984 | } |
| 4985 | |
| 4986 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4987 | const struct alc_fixup *fix, int action) |
| 4988 | { |
| 4989 | struct alc_spec *spec = codec->spec; |
| 4990 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4991 | /* although the machine has only one output pin, we need to |
| 4992 | * toggle GPIO1 according to the jack state |
| 4993 | */ |
| 4994 | spec->automute_hook = alc260_gpio1_automute; |
| 4995 | spec->detect_hp = 1; |
| 4996 | spec->automute_speaker = 1; |
| 4997 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4998 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 4999 | alc_hp_automute); |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame^] | 5000 | snd_hda_add_verbs(codec, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5001 | } |
| 5002 | } |
| 5003 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5004 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 5005 | const struct alc_fixup *fix, int action) |
| 5006 | { |
| 5007 | struct alc_spec *spec = codec->spec; |
| 5008 | static const struct alc_pincfg pincfgs[] = { |
| 5009 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 5010 | { 0x12, 0x90a60160 }, /* int mic */ |
| 5011 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 5012 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 5013 | /* disable bogus I/O pins */ |
| 5014 | { 0x10, 0x411111f0 }, |
| 5015 | { 0x11, 0x411111f0 }, |
| 5016 | { 0x14, 0x411111f0 }, |
| 5017 | { 0x15, 0x411111f0 }, |
| 5018 | { 0x16, 0x411111f0 }, |
| 5019 | { 0x17, 0x411111f0 }, |
| 5020 | { 0x19, 0x411111f0 }, |
| 5021 | { } |
| 5022 | }; |
| 5023 | |
| 5024 | switch (action) { |
| 5025 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 5026 | alc_apply_pincfgs(codec, pincfgs); |
| 5027 | break; |
| 5028 | case ALC_FIXUP_ACT_PROBE: |
| 5029 | spec->init_amp = ALC_INIT_NONE; |
| 5030 | break; |
| 5031 | } |
| 5032 | } |
| 5033 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5034 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5035 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5036 | .type = ALC_FIXUP_PINS, |
| 5037 | .v.pins = (const struct alc_pincfg[]) { |
| 5038 | { 0x11, 0x90130110 }, /* speaker */ |
| 5039 | { } |
| 5040 | } |
| 5041 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5042 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 5043 | .type = ALC_FIXUP_PINS, |
| 5044 | .v.pins = (const struct alc_pincfg[]) { |
| 5045 | { 0x0f, 0x01214000 }, /* HP */ |
| 5046 | { } |
| 5047 | } |
| 5048 | }, |
| 5049 | [ALC260_FIXUP_COEF] = { |
| 5050 | .type = ALC_FIXUP_VERBS, |
| 5051 | .v.verbs = (const struct hda_verb[]) { |
| 5052 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5053 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 5054 | { } |
| 5055 | }, |
| 5056 | .chained = true, |
| 5057 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5058 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5059 | [ALC260_FIXUP_GPIO1] = { |
| 5060 | .type = ALC_FIXUP_VERBS, |
| 5061 | .v.verbs = alc_gpio1_init_verbs, |
| 5062 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5063 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 5064 | .type = ALC_FIXUP_FUNC, |
| 5065 | .v.func = alc260_fixup_gpio1_toggle, |
| 5066 | .chained = true, |
| 5067 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5068 | }, |
| 5069 | [ALC260_FIXUP_REPLACER] = { |
| 5070 | .type = ALC_FIXUP_VERBS, |
| 5071 | .v.verbs = (const struct hda_verb[]) { |
| 5072 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5073 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5074 | { } |
| 5075 | }, |
| 5076 | .chained = true, |
| 5077 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 5078 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5079 | [ALC260_FIXUP_HP_B1900] = { |
| 5080 | .type = ALC_FIXUP_FUNC, |
| 5081 | .v.func = alc260_fixup_gpio1_toggle, |
| 5082 | .chained = true, |
| 5083 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5084 | }, |
| 5085 | [ALC260_FIXUP_KN1] = { |
| 5086 | .type = ALC_FIXUP_FUNC, |
| 5087 | .v.func = alc260_fixup_kn1, |
| 5088 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5089 | }; |
| 5090 | |
| 5091 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5092 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5093 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5094 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5095 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5096 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 5097 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5098 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5099 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5100 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5101 | {} |
| 5102 | }; |
| 5103 | |
| 5104 | /* |
| 5105 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5106 | static int patch_alc260(struct hda_codec *codec) |
| 5107 | { |
| 5108 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5109 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5110 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5111 | err = alc_alloc_spec(codec, 0x07); |
| 5112 | if (err < 0) |
| 5113 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5114 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5115 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5116 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5117 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5118 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5119 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5120 | /* automatic parse from the BIOS config */ |
| 5121 | err = alc260_parse_auto_config(codec); |
| 5122 | if (err < 0) |
| 5123 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5124 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5125 | if (!spec->no_analog) { |
| 5126 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5127 | if (err < 0) |
| 5128 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5129 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5130 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5131 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5132 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5133 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5134 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5135 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5136 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5137 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5138 | |
| 5139 | error: |
| 5140 | alc_free(codec); |
| 5141 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5142 | } |
| 5143 | |
| 5144 | |
| 5145 | /* |
| 5146 | * ALC882/883/885/888/889 support |
| 5147 | * |
| 5148 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5149 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5150 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5151 | * 6-channel independent captures. |
| 5152 | * |
| 5153 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5154 | * driver yet). |
| 5155 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5156 | |
| 5157 | /* |
| 5158 | * Pin config fixes |
| 5159 | */ |
| 5160 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5161 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5162 | ALC882_FIXUP_LENOVO_Y530, |
| 5163 | ALC882_FIXUP_PB_M5210, |
| 5164 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5165 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5166 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5167 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5168 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5169 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5170 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5171 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5172 | ALC882_FIXUP_GPIO1, |
| 5173 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5174 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5175 | ALC889_FIXUP_COEF, |
| 5176 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5177 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5178 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5179 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5180 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5181 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5182 | ALC889_FIXUP_MBP_VREF, |
| 5183 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5184 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5185 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5186 | }; |
| 5187 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5188 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5189 | const struct alc_fixup *fix, int action) |
| 5190 | { |
| 5191 | if (action != ALC_FIXUP_ACT_INIT) |
| 5192 | return; |
| 5193 | alc889_coef_init(codec); |
| 5194 | } |
| 5195 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5196 | /* toggle speaker-output according to the hp-jack state */ |
| 5197 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5198 | { |
| 5199 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5200 | |
| 5201 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5202 | AC_VERB_GET_GPIO_DATA, 0); |
| 5203 | |
| 5204 | if (!muted) |
| 5205 | gpiostate |= (1 << pin); |
| 5206 | else |
| 5207 | gpiostate &= ~(1 << pin); |
| 5208 | |
| 5209 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5210 | AC_VERB_GET_GPIO_MASK, 0); |
| 5211 | gpiomask |= (1 << pin); |
| 5212 | |
| 5213 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5214 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5215 | gpiodir |= (1 << pin); |
| 5216 | |
| 5217 | |
| 5218 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5219 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5220 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5221 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5222 | |
| 5223 | msleep(1); |
| 5224 | |
| 5225 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5226 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5227 | } |
| 5228 | |
| 5229 | /* set up GPIO at initialization */ |
| 5230 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5231 | const struct alc_fixup *fix, int action) |
| 5232 | { |
| 5233 | if (action != ALC_FIXUP_ACT_INIT) |
| 5234 | return; |
| 5235 | alc882_gpio_mute(codec, 0, 0); |
| 5236 | alc882_gpio_mute(codec, 1, 0); |
| 5237 | } |
| 5238 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5239 | /* Fix the connection of some pins for ALC889: |
| 5240 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5241 | * work correctly (bko#42740) |
| 5242 | */ |
| 5243 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5244 | const struct alc_fixup *fix, int action) |
| 5245 | { |
| 5246 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5247 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5248 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5249 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5250 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5251 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5252 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5253 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5254 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5255 | /* restore the connections */ |
| 5256 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5257 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5258 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5259 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5260 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5261 | } |
| 5262 | } |
| 5263 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5264 | /* Set VREF on HP pin */ |
| 5265 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5266 | const struct alc_fixup *fix, int action) |
| 5267 | { |
| 5268 | struct alc_spec *spec = codec->spec; |
| 5269 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5270 | int i; |
| 5271 | |
| 5272 | if (action != ALC_FIXUP_ACT_INIT) |
| 5273 | return; |
| 5274 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5275 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5276 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5277 | continue; |
| 5278 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5279 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5280 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5281 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5282 | spec->keep_vref_in_automute = 1; |
| 5283 | break; |
| 5284 | } |
| 5285 | } |
| 5286 | |
| 5287 | /* Set VREF on speaker pins on imac91 */ |
| 5288 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5289 | const struct alc_fixup *fix, int action) |
| 5290 | { |
| 5291 | struct alc_spec *spec = codec->spec; |
| 5292 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5293 | int i; |
| 5294 | |
| 5295 | if (action != ALC_FIXUP_ACT_INIT) |
| 5296 | return; |
| 5297 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5298 | unsigned int val; |
| 5299 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5300 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5301 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5302 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5303 | } |
| 5304 | spec->keep_vref_in_automute = 1; |
| 5305 | } |
| 5306 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5307 | /* Don't take HP output as primary |
| 5308 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5309 | */ |
| 5310 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5311 | const struct alc_fixup *fix, int action) |
| 5312 | { |
| 5313 | struct alc_spec *spec = codec->spec; |
| 5314 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5315 | spec->no_primary_hp = 1; |
| 5316 | } |
| 5317 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5318 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5319 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5320 | .type = ALC_FIXUP_PINS, |
| 5321 | .v.pins = (const struct alc_pincfg[]) { |
| 5322 | { 0x15, 0x01080104 }, /* side */ |
| 5323 | { 0x16, 0x01011012 }, /* rear */ |
| 5324 | { 0x17, 0x01016011 }, /* clfe */ |
| 5325 | { } |
| 5326 | } |
| 5327 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5328 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5329 | .type = ALC_FIXUP_PINS, |
| 5330 | .v.pins = (const struct alc_pincfg[]) { |
| 5331 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5332 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5333 | { } |
| 5334 | } |
| 5335 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5336 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5337 | .type = ALC_FIXUP_VERBS, |
| 5338 | .v.verbs = (const struct hda_verb[]) { |
| 5339 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5340 | {} |
| 5341 | } |
| 5342 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5343 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5344 | .type = ALC_FIXUP_FUNC, |
| 5345 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5346 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5347 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5348 | .type = ALC_FIXUP_PINS, |
| 5349 | .v.pins = (const struct alc_pincfg[]) { |
| 5350 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5351 | { } |
| 5352 | } |
| 5353 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5354 | [ALC889_FIXUP_CD] = { |
| 5355 | .type = ALC_FIXUP_PINS, |
| 5356 | .v.pins = (const struct alc_pincfg[]) { |
| 5357 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5358 | { } |
| 5359 | } |
| 5360 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5361 | [ALC889_FIXUP_VAIO_TT] = { |
| 5362 | .type = ALC_FIXUP_PINS, |
| 5363 | .v.pins = (const struct alc_pincfg[]) { |
| 5364 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5365 | { } |
| 5366 | } |
| 5367 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5368 | [ALC888_FIXUP_EEE1601] = { |
| 5369 | .type = ALC_FIXUP_VERBS, |
| 5370 | .v.verbs = (const struct hda_verb[]) { |
| 5371 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5372 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5373 | { } |
| 5374 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5375 | }, |
| 5376 | [ALC882_FIXUP_EAPD] = { |
| 5377 | .type = ALC_FIXUP_VERBS, |
| 5378 | .v.verbs = (const struct hda_verb[]) { |
| 5379 | /* change to EAPD mode */ |
| 5380 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5381 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5382 | { } |
| 5383 | } |
| 5384 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5385 | [ALC883_FIXUP_EAPD] = { |
| 5386 | .type = ALC_FIXUP_VERBS, |
| 5387 | .v.verbs = (const struct hda_verb[]) { |
| 5388 | /* change to EAPD mode */ |
| 5389 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5390 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5391 | { } |
| 5392 | } |
| 5393 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5394 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5395 | .type = ALC_FIXUP_VERBS, |
| 5396 | .v.verbs = (const struct hda_verb[]) { |
| 5397 | /* eanable EAPD on Acer laptops */ |
| 5398 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5399 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5400 | { } |
| 5401 | } |
| 5402 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5403 | [ALC882_FIXUP_GPIO1] = { |
| 5404 | .type = ALC_FIXUP_VERBS, |
| 5405 | .v.verbs = alc_gpio1_init_verbs, |
| 5406 | }, |
| 5407 | [ALC882_FIXUP_GPIO2] = { |
| 5408 | .type = ALC_FIXUP_VERBS, |
| 5409 | .v.verbs = alc_gpio2_init_verbs, |
| 5410 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5411 | [ALC882_FIXUP_GPIO3] = { |
| 5412 | .type = ALC_FIXUP_VERBS, |
| 5413 | .v.verbs = alc_gpio3_init_verbs, |
| 5414 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5415 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5416 | .type = ALC_FIXUP_VERBS, |
| 5417 | .v.verbs = alc_gpio1_init_verbs, |
| 5418 | .chained = true, |
| 5419 | .chain_id = ALC882_FIXUP_EAPD, |
| 5420 | }, |
| 5421 | [ALC889_FIXUP_COEF] = { |
| 5422 | .type = ALC_FIXUP_FUNC, |
| 5423 | .v.func = alc889_fixup_coef, |
| 5424 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5425 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5426 | .type = ALC_FIXUP_PINS, |
| 5427 | .v.pins = (const struct alc_pincfg[]) { |
| 5428 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5429 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5430 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5431 | }, |
| 5432 | .chained = true, |
| 5433 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5434 | }, |
| 5435 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5436 | .type = ALC_FIXUP_PINS, |
| 5437 | .v.pins = (const struct alc_pincfg[]) { |
| 5438 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5439 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5440 | { } |
| 5441 | }, |
| 5442 | .chained = true, |
| 5443 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5444 | }, |
| 5445 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5446 | /* additional init verbs for Acer Aspire 8930G */ |
| 5447 | .type = ALC_FIXUP_VERBS, |
| 5448 | .v.verbs = (const struct hda_verb[]) { |
| 5449 | /* Enable all DACs */ |
| 5450 | /* DAC DISABLE/MUTE 1? */ |
| 5451 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5452 | * apparently. Init=0x38 */ |
| 5453 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5454 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5455 | /* DAC DISABLE/MUTE 2? */ |
| 5456 | /* some bit here disables the other DACs. |
| 5457 | * Init=0x4900 */ |
| 5458 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5459 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5460 | /* DMIC fix |
| 5461 | * This laptop has a stereo digital microphone. |
| 5462 | * The mics are only 1cm apart which makes the stereo |
| 5463 | * useless. However, either the mic or the ALC889 |
| 5464 | * makes the signal become a difference/sum signal |
| 5465 | * instead of standard stereo, which is annoying. |
| 5466 | * So instead we flip this bit which makes the |
| 5467 | * codec replicate the sum signal to both channels, |
| 5468 | * turning it into a normal mono mic. |
| 5469 | */ |
| 5470 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5471 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5472 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5473 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5474 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5475 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5476 | }, |
| 5477 | .chained = true, |
| 5478 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5479 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5480 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5481 | .type = ALC_FIXUP_FUNC, |
| 5482 | .v.func = alc885_fixup_macpro_gpio, |
| 5483 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5484 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5485 | .type = ALC_FIXUP_FUNC, |
| 5486 | .v.func = alc889_fixup_dac_route, |
| 5487 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5488 | [ALC889_FIXUP_MBP_VREF] = { |
| 5489 | .type = ALC_FIXUP_FUNC, |
| 5490 | .v.func = alc889_fixup_mbp_vref, |
| 5491 | .chained = true, |
| 5492 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5493 | }, |
| 5494 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5495 | .type = ALC_FIXUP_FUNC, |
| 5496 | .v.func = alc889_fixup_imac91_vref, |
| 5497 | .chained = true, |
| 5498 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5499 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5500 | [ALC882_FIXUP_INV_DMIC] = { |
| 5501 | .type = ALC_FIXUP_FUNC, |
| 5502 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5503 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5504 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5505 | .type = ALC_FIXUP_FUNC, |
| 5506 | .v.func = alc882_fixup_no_primary_hp, |
| 5507 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5508 | }; |
| 5509 | |
| 5510 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5511 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5512 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5513 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5514 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5515 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5516 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5517 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5518 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5519 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5520 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5521 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5522 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5523 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5524 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5525 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5526 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5527 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5528 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5529 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5530 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5531 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5532 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5533 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5534 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5535 | 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] | 5536 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5537 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5538 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5539 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5540 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5541 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5542 | 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] | 5543 | |
| 5544 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5545 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5546 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5547 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5548 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5549 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5550 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5551 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5552 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5553 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5554 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5555 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5556 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5557 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5558 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5559 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5560 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5561 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5562 | 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] | 5563 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5564 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5565 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5566 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5567 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5568 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5569 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5570 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5571 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5572 | 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] | 5573 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5574 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5575 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5576 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5577 | {} |
| 5578 | }; |
| 5579 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5580 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5581 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5582 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5583 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5584 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5585 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5586 | {} |
| 5587 | }; |
| 5588 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5589 | /* |
| 5590 | * BIOS auto configuration |
| 5591 | */ |
| 5592 | /* almost identical with ALC880 parser... */ |
| 5593 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5594 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5595 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5596 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5597 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5598 | } |
| 5599 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5600 | /* |
| 5601 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5602 | static int patch_alc882(struct hda_codec *codec) |
| 5603 | { |
| 5604 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5605 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5606 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5607 | err = alc_alloc_spec(codec, 0x0b); |
| 5608 | if (err < 0) |
| 5609 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5610 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5611 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5612 | |
| 5613 | switch (codec->vendor_id) { |
| 5614 | case 0x10ec0882: |
| 5615 | case 0x10ec0885: |
| 5616 | break; |
| 5617 | default: |
| 5618 | /* ALC883 and variants */ |
| 5619 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5620 | break; |
| 5621 | } |
| 5622 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5623 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5624 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5625 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5626 | |
| 5627 | alc_auto_parse_customize_define(codec); |
| 5628 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5629 | /* automatic parse from the BIOS config */ |
| 5630 | err = alc882_parse_auto_config(codec); |
| 5631 | if (err < 0) |
| 5632 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5633 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5634 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5635 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5636 | if (err < 0) |
| 5637 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5638 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5639 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5640 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5641 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5642 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5643 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5644 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5645 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5646 | |
| 5647 | error: |
| 5648 | alc_free(codec); |
| 5649 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5650 | } |
| 5651 | |
| 5652 | |
| 5653 | /* |
| 5654 | * ALC262 support |
| 5655 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5656 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5657 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5658 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5659 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5660 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5661 | } |
| 5662 | |
| 5663 | /* |
| 5664 | * Pin config fixes |
| 5665 | */ |
| 5666 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5667 | ALC262_FIXUP_FSC_H270, |
| 5668 | ALC262_FIXUP_HP_Z200, |
| 5669 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5670 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5671 | ALC262_FIXUP_BENQ, |
| 5672 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5673 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5674 | }; |
| 5675 | |
| 5676 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5677 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5678 | .type = ALC_FIXUP_PINS, |
| 5679 | .v.pins = (const struct alc_pincfg[]) { |
| 5680 | { 0x14, 0x99130110 }, /* speaker */ |
| 5681 | { 0x15, 0x0221142f }, /* front HP */ |
| 5682 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5683 | { } |
| 5684 | } |
| 5685 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5686 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5687 | .type = ALC_FIXUP_PINS, |
| 5688 | .v.pins = (const struct alc_pincfg[]) { |
| 5689 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5690 | { } |
| 5691 | } |
| 5692 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5693 | [ALC262_FIXUP_TYAN] = { |
| 5694 | .type = ALC_FIXUP_PINS, |
| 5695 | .v.pins = (const struct alc_pincfg[]) { |
| 5696 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5697 | { } |
| 5698 | } |
| 5699 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5700 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5701 | .type = ALC_FIXUP_VERBS, |
| 5702 | .v.verbs = (const struct hda_verb[]) { |
| 5703 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5704 | {} |
| 5705 | }, |
| 5706 | .chained = true, |
| 5707 | .chain_id = ALC262_FIXUP_BENQ, |
| 5708 | }, |
| 5709 | [ALC262_FIXUP_BENQ] = { |
| 5710 | .type = ALC_FIXUP_VERBS, |
| 5711 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5712 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5713 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5714 | {} |
| 5715 | } |
| 5716 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5717 | [ALC262_FIXUP_BENQ_T31] = { |
| 5718 | .type = ALC_FIXUP_VERBS, |
| 5719 | .v.verbs = (const struct hda_verb[]) { |
| 5720 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5721 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5722 | {} |
| 5723 | } |
| 5724 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5725 | [ALC262_FIXUP_INV_DMIC] = { |
| 5726 | .type = ALC_FIXUP_FUNC, |
| 5727 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5728 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5729 | }; |
| 5730 | |
| 5731 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5732 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5733 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5734 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5735 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5736 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5737 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5738 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5739 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5740 | {} |
| 5741 | }; |
| 5742 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5743 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5744 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5745 | {} |
| 5746 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5747 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5748 | /* |
| 5749 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5750 | static int patch_alc262(struct hda_codec *codec) |
| 5751 | { |
| 5752 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5753 | int err; |
| 5754 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5755 | err = alc_alloc_spec(codec, 0x0b); |
| 5756 | if (err < 0) |
| 5757 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5758 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5759 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 5760 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5761 | |
| 5762 | #if 0 |
| 5763 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5764 | * under-run |
| 5765 | */ |
| 5766 | { |
| 5767 | int tmp; |
| 5768 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5769 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5770 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5771 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5772 | } |
| 5773 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5774 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5775 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5776 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5777 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +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 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5780 | alc_auto_parse_customize_define(codec); |
| 5781 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5782 | /* automatic parse from the BIOS config */ |
| 5783 | err = alc262_parse_auto_config(codec); |
| 5784 | if (err < 0) |
| 5785 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5786 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +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 | spec->shutup = alc_eapd_shutup; |
| 5796 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5797 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5798 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5799 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5800 | |
| 5801 | error: |
| 5802 | alc_free(codec); |
| 5803 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5804 | } |
| 5805 | |
| 5806 | /* |
| 5807 | * ALC268 |
| 5808 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5809 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5810 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5811 | .ops = &snd_hda_bind_sw, |
| 5812 | .values = { |
| 5813 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5814 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5815 | 0 |
| 5816 | }, |
| 5817 | }; |
| 5818 | |
| 5819 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5820 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5821 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5822 | { } |
| 5823 | }; |
| 5824 | |
| 5825 | /* set PCBEEP vol = 0, mute connections */ |
| 5826 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5827 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5828 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5829 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5830 | { } |
| 5831 | }; |
| 5832 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5833 | enum { |
| 5834 | ALC268_FIXUP_INV_DMIC, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5835 | ALC268_FIXUP_HP_EAPD, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5836 | }; |
| 5837 | |
| 5838 | static const struct alc_fixup alc268_fixups[] = { |
| 5839 | [ALC268_FIXUP_INV_DMIC] = { |
| 5840 | .type = ALC_FIXUP_FUNC, |
| 5841 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5842 | }, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5843 | [ALC268_FIXUP_HP_EAPD] = { |
| 5844 | .type = ALC_FIXUP_VERBS, |
| 5845 | .v.verbs = (const struct hda_verb[]) { |
| 5846 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5847 | {} |
| 5848 | } |
| 5849 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5850 | }; |
| 5851 | |
| 5852 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 5853 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5854 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
| 5855 | {} |
| 5856 | }; |
| 5857 | |
| 5858 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 5859 | /* below is codec SSID since multiple Toshiba laptops have the |
| 5860 | * same PCI SSID 1179:ff00 |
| 5861 | */ |
| 5862 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5863 | {} |
| 5864 | }; |
| 5865 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5866 | /* |
| 5867 | * BIOS auto configuration |
| 5868 | */ |
| 5869 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5870 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5871 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5872 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5873 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5874 | if (err > 0) { |
| 5875 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5876 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame^] | 5877 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5878 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5879 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5880 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5881 | } |
| 5882 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5883 | /* |
| 5884 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5885 | static int patch_alc268(struct hda_codec *codec) |
| 5886 | { |
| 5887 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5888 | int i, has_beep, err; |
| 5889 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5890 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5891 | err = alc_alloc_spec(codec, 0); |
| 5892 | if (err < 0) |
| 5893 | return err; |
| 5894 | |
| 5895 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5896 | |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5897 | alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5898 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5899 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5900 | /* automatic parse from the BIOS config */ |
| 5901 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5902 | if (err < 0) |
| 5903 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5904 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5905 | has_beep = 0; |
| 5906 | for (i = 0; i < spec->num_mixers; i++) { |
| 5907 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5908 | has_beep = 1; |
| 5909 | break; |
| 5910 | } |
| 5911 | } |
| 5912 | |
| 5913 | if (has_beep) { |
| 5914 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5915 | if (err < 0) |
| 5916 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5917 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5918 | /* override the amp caps for beep generator */ |
| 5919 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5920 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5921 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5922 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5923 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5924 | } |
| 5925 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5926 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5927 | spec->shutup = alc_eapd_shutup; |
| 5928 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5929 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5930 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5931 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5932 | |
| 5933 | error: |
| 5934 | alc_free(codec); |
| 5935 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5936 | } |
| 5937 | |
| 5938 | /* |
| 5939 | * ALC269 |
| 5940 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5941 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5942 | .substreams = 1, |
| 5943 | .channels_min = 2, |
| 5944 | .channels_max = 8, |
| 5945 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5946 | /* NID is set in alc_build_pcms */ |
| 5947 | .ops = { |
| 5948 | .open = alc_playback_pcm_open, |
| 5949 | .prepare = alc_playback_pcm_prepare, |
| 5950 | .cleanup = alc_playback_pcm_cleanup |
| 5951 | }, |
| 5952 | }; |
| 5953 | |
| 5954 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5955 | .substreams = 1, |
| 5956 | .channels_min = 2, |
| 5957 | .channels_max = 2, |
| 5958 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5959 | /* NID is set in alc_build_pcms */ |
| 5960 | }; |
| 5961 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5962 | /* different alc269-variants */ |
| 5963 | enum { |
| 5964 | ALC269_TYPE_ALC269VA, |
| 5965 | ALC269_TYPE_ALC269VB, |
| 5966 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5967 | ALC269_TYPE_ALC269VD, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5968 | ALC269_TYPE_ALC280, |
| 5969 | ALC269_TYPE_ALC282, |
| 5970 | ALC269_TYPE_ALC284, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5971 | }; |
| 5972 | |
| 5973 | /* |
| 5974 | * BIOS auto configuration |
| 5975 | */ |
| 5976 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5977 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5978 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5979 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5980 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5981 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5982 | const hda_nid_t *ssids; |
| 5983 | |
| 5984 | switch (spec->codec_variant) { |
| 5985 | case ALC269_TYPE_ALC269VA: |
| 5986 | case ALC269_TYPE_ALC269VC: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5987 | case ALC269_TYPE_ALC280: |
| 5988 | case ALC269_TYPE_ALC284: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5989 | ssids = alc269va_ssids; |
| 5990 | break; |
| 5991 | case ALC269_TYPE_ALC269VB: |
| 5992 | case ALC269_TYPE_ALC269VD: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5993 | case ALC269_TYPE_ALC282: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5994 | ssids = alc269_ssids; |
| 5995 | break; |
| 5996 | default: |
| 5997 | ssids = alc269_ssids; |
| 5998 | break; |
| 5999 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6000 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6001 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6002 | } |
| 6003 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6004 | 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] | 6005 | { |
| 6006 | int val = alc_read_coef_idx(codec, 0x04); |
| 6007 | if (power_up) |
| 6008 | val |= 1 << 11; |
| 6009 | else |
| 6010 | val &= ~(1 << 11); |
| 6011 | alc_write_coef_idx(codec, 0x04, val); |
| 6012 | } |
| 6013 | |
| 6014 | static void alc269_shutup(struct hda_codec *codec) |
| 6015 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6016 | struct alc_spec *spec = codec->spec; |
| 6017 | |
| 6018 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 6019 | return; |
| 6020 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6021 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6022 | alc269vb_toggle_power_output(codec, 0); |
| 6023 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
| 6024 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6025 | msleep(150); |
| 6026 | } |
| 6027 | } |
| 6028 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6029 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6030 | static int alc269_resume(struct hda_codec *codec) |
| 6031 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6032 | struct alc_spec *spec = codec->spec; |
| 6033 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6034 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6035 | alc269vb_toggle_power_output(codec, 0); |
| 6036 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6037 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6038 | msleep(150); |
| 6039 | } |
| 6040 | |
| 6041 | codec->patch_ops.init(codec); |
| 6042 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6043 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6044 | alc269vb_toggle_power_output(codec, 1); |
| 6045 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6046 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6047 | msleep(200); |
| 6048 | } |
| 6049 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6050 | snd_hda_codec_resume_amp(codec); |
| 6051 | snd_hda_codec_resume_cache(codec); |
| 6052 | hda_call_check_power_status(codec, 0x01); |
| 6053 | return 0; |
| 6054 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6055 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6056 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6057 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 6058 | const struct alc_fixup *fix, int action) |
| 6059 | { |
| 6060 | struct alc_spec *spec = codec->spec; |
| 6061 | |
| 6062 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6063 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6064 | } |
| 6065 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6066 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 6067 | const struct alc_fixup *fix, int action) |
| 6068 | { |
| 6069 | int coef; |
| 6070 | |
| 6071 | if (action != ALC_FIXUP_ACT_INIT) |
| 6072 | return; |
| 6073 | coef = alc_read_coef_idx(codec, 0x1e); |
| 6074 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 6075 | } |
| 6076 | |
| 6077 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 6078 | const struct alc_fixup *fix, int action) |
| 6079 | { |
| 6080 | static const struct hda_verb verbs[] = { |
| 6081 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 6082 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 6083 | {} |
| 6084 | }; |
| 6085 | unsigned int cfg; |
| 6086 | |
| 6087 | if (strcmp(codec->chip_name, "ALC271X")) |
| 6088 | return; |
| 6089 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 6090 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 6091 | snd_hda_sequence_write(codec, verbs); |
| 6092 | } |
| 6093 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6094 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 6095 | const struct alc_fixup *fix, int action) |
| 6096 | { |
| 6097 | struct alc_spec *spec = codec->spec; |
| 6098 | |
| 6099 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6100 | return; |
| 6101 | |
| 6102 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 6103 | * fix the sample rate of analog I/O to 44.1kHz |
| 6104 | */ |
| 6105 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 6106 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 6107 | } |
| 6108 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6109 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 6110 | const struct alc_fixup *fix, int action) |
| 6111 | { |
| 6112 | int coef; |
| 6113 | |
| 6114 | if (action != ALC_FIXUP_ACT_INIT) |
| 6115 | return; |
| 6116 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 6117 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 6118 | * Below is a workaround specific to ALC269 to control the dmic |
| 6119 | * signal source as mono. |
| 6120 | */ |
| 6121 | coef = alc_read_coef_idx(codec, 0x07); |
| 6122 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 6123 | } |
| 6124 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6125 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 6126 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 6127 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6128 | |
| 6129 | snd_hda_codec_write(codec, 0x20, 0, |
| 6130 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6131 | snd_hda_codec_write(codec, 0x20, 0, |
| 6132 | AC_VERB_SET_PROC_COEF, 0x680); |
| 6133 | |
| 6134 | snd_hda_codec_write(codec, 0x20, 0, |
| 6135 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6136 | snd_hda_codec_write(codec, 0x20, 0, |
| 6137 | AC_VERB_SET_PROC_COEF, 0x480); |
| 6138 | } |
| 6139 | |
| 6140 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 6141 | const struct alc_fixup *fix, int action) |
| 6142 | { |
| 6143 | struct alc_spec *spec = codec->spec; |
| 6144 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6145 | return; |
| 6146 | spec->automute_hook = alc269_quanta_automute; |
| 6147 | } |
| 6148 | |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6149 | /* update mute-LED according to the speaker mute state via mic1 VREF pin */ |
| 6150 | static void alc269_fixup_mic1_mute_hook(void *private_data, int enabled) |
| 6151 | { |
| 6152 | struct hda_codec *codec = private_data; |
| 6153 | unsigned int pinval = AC_PINCTL_IN_EN + (enabled ? |
| 6154 | AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); |
| 6155 | snd_hda_set_pin_ctl_cache(codec, 0x18, pinval); |
| 6156 | } |
| 6157 | |
| 6158 | static void alc269_fixup_mic1_mute(struct hda_codec *codec, |
| 6159 | const struct alc_fixup *fix, int action) |
| 6160 | { |
| 6161 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 6162 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6163 | spec->vmaster_mute.hook = alc269_fixup_mic1_mute_hook; |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6164 | } |
| 6165 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6166 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 6167 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 6168 | { |
| 6169 | struct hda_codec *codec = private_data; |
| 6170 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6171 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6172 | } |
| 6173 | |
| 6174 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 6175 | const struct alc_fixup *fix, int action) |
| 6176 | { |
| 6177 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 6178 | if (action == ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6179 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6180 | } |
| 6181 | |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6182 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
| 6183 | const struct alc_fixup *fix, |
| 6184 | int action) |
| 6185 | { |
| 6186 | struct alc_spec *spec = codec->spec; |
| 6187 | |
| 6188 | if (action == ALC_FIXUP_ACT_PROBE) |
| 6189 | snd_hda_jack_set_gating_jack(codec, spec->ext_mic_pin, |
| 6190 | spec->autocfg.hp_pins[0]); |
| 6191 | } |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6192 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6193 | enum { |
| 6194 | ALC269_FIXUP_SONY_VAIO, |
| 6195 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 6196 | ALC269_FIXUP_DELL_M101Z, |
| 6197 | ALC269_FIXUP_SKU_IGNORE, |
| 6198 | ALC269_FIXUP_ASUS_G73JW, |
| 6199 | ALC269_FIXUP_LENOVO_EAPD, |
| 6200 | ALC275_FIXUP_SONY_HWEQ, |
| 6201 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6202 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6203 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6204 | ALC269_FIXUP_QUANTA_MUTE, |
| 6205 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6206 | ALC269_FIXUP_AMIC, |
| 6207 | ALC269_FIXUP_DMIC, |
| 6208 | ALC269VB_FIXUP_AMIC, |
| 6209 | ALC269VB_FIXUP_DMIC, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6210 | ALC269_FIXUP_MIC1_MUTE_LED, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6211 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6212 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6213 | ALC269_FIXUP_LENOVO_DOCK, |
| 6214 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6215 | ALC271_FIXUP_AMIC_MIC2, |
| 6216 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6217 | }; |
| 6218 | |
| 6219 | static const struct alc_fixup alc269_fixups[] = { |
| 6220 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6221 | .type = ALC_FIXUP_VERBS, |
| 6222 | .v.verbs = (const struct hda_verb[]) { |
| 6223 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6224 | {} |
| 6225 | } |
| 6226 | }, |
| 6227 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6228 | .type = ALC_FIXUP_VERBS, |
| 6229 | .v.verbs = (const struct hda_verb[]) { |
| 6230 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6231 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6232 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6233 | { } |
| 6234 | }, |
| 6235 | .chained = true, |
| 6236 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6237 | }, |
| 6238 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6239 | .type = ALC_FIXUP_VERBS, |
| 6240 | .v.verbs = (const struct hda_verb[]) { |
| 6241 | /* Enables internal speaker */ |
| 6242 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6243 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6244 | {} |
| 6245 | } |
| 6246 | }, |
| 6247 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6248 | .type = ALC_FIXUP_FUNC, |
| 6249 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6250 | }, |
| 6251 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6252 | .type = ALC_FIXUP_PINS, |
| 6253 | .v.pins = (const struct alc_pincfg[]) { |
| 6254 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6255 | { } |
| 6256 | } |
| 6257 | }, |
| 6258 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6259 | .type = ALC_FIXUP_VERBS, |
| 6260 | .v.verbs = (const struct hda_verb[]) { |
| 6261 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6262 | {} |
| 6263 | } |
| 6264 | }, |
| 6265 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6266 | .type = ALC_FIXUP_FUNC, |
| 6267 | .v.func = alc269_fixup_hweq, |
| 6268 | .chained = true, |
| 6269 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6270 | }, |
| 6271 | [ALC271_FIXUP_DMIC] = { |
| 6272 | .type = ALC_FIXUP_FUNC, |
| 6273 | .v.func = alc271_fixup_dmic, |
| 6274 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6275 | [ALC269_FIXUP_PCM_44K] = { |
| 6276 | .type = ALC_FIXUP_FUNC, |
| 6277 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6278 | .chained = true, |
| 6279 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6280 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6281 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6282 | .type = ALC_FIXUP_FUNC, |
| 6283 | .v.func = alc269_fixup_stereo_dmic, |
| 6284 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6285 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6286 | .type = ALC_FIXUP_FUNC, |
| 6287 | .v.func = alc269_fixup_quanta_mute, |
| 6288 | }, |
| 6289 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6290 | .type = ALC_FIXUP_PINS, |
| 6291 | .v.pins = (const struct alc_pincfg[]) { |
| 6292 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6293 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6294 | { } |
| 6295 | }, |
| 6296 | .chained = true, |
| 6297 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6298 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6299 | [ALC269_FIXUP_AMIC] = { |
| 6300 | .type = ALC_FIXUP_PINS, |
| 6301 | .v.pins = (const struct alc_pincfg[]) { |
| 6302 | { 0x14, 0x99130110 }, /* speaker */ |
| 6303 | { 0x15, 0x0121401f }, /* HP out */ |
| 6304 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6305 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6306 | { } |
| 6307 | }, |
| 6308 | }, |
| 6309 | [ALC269_FIXUP_DMIC] = { |
| 6310 | .type = ALC_FIXUP_PINS, |
| 6311 | .v.pins = (const struct alc_pincfg[]) { |
| 6312 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6313 | { 0x14, 0x99130110 }, /* speaker */ |
| 6314 | { 0x15, 0x0121401f }, /* HP out */ |
| 6315 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6316 | { } |
| 6317 | }, |
| 6318 | }, |
| 6319 | [ALC269VB_FIXUP_AMIC] = { |
| 6320 | .type = ALC_FIXUP_PINS, |
| 6321 | .v.pins = (const struct alc_pincfg[]) { |
| 6322 | { 0x14, 0x99130110 }, /* speaker */ |
| 6323 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6324 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6325 | { 0x21, 0x0121401f }, /* HP out */ |
| 6326 | { } |
| 6327 | }, |
| 6328 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6329 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6330 | .type = ALC_FIXUP_PINS, |
| 6331 | .v.pins = (const struct alc_pincfg[]) { |
| 6332 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6333 | { 0x14, 0x99130110 }, /* speaker */ |
| 6334 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6335 | { 0x21, 0x0121401f }, /* HP out */ |
| 6336 | { } |
| 6337 | }, |
| 6338 | }, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6339 | [ALC269_FIXUP_MIC1_MUTE_LED] = { |
| 6340 | .type = ALC_FIXUP_FUNC, |
| 6341 | .v.func = alc269_fixup_mic1_mute, |
| 6342 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6343 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6344 | .type = ALC_FIXUP_FUNC, |
| 6345 | .v.func = alc269_fixup_mic2_mute, |
| 6346 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6347 | [ALC269_FIXUP_INV_DMIC] = { |
| 6348 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6349 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6350 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6351 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6352 | .type = ALC_FIXUP_PINS, |
| 6353 | .v.pins = (const struct alc_pincfg[]) { |
| 6354 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6355 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6356 | { } |
| 6357 | }, |
| 6358 | .chained = true, |
| 6359 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6360 | }, |
| 6361 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6362 | .type = ALC_FIXUP_FUNC, |
| 6363 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6364 | }, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6365 | [ALC271_FIXUP_AMIC_MIC2] = { |
| 6366 | .type = ALC_FIXUP_PINS, |
| 6367 | .v.pins = (const struct alc_pincfg[]) { |
| 6368 | { 0x14, 0x99130110 }, /* speaker */ |
| 6369 | { 0x19, 0x01a19c20 }, /* mic */ |
| 6370 | { 0x1b, 0x99a7012f }, /* int-mic */ |
| 6371 | { 0x21, 0x0121401f }, /* HP out */ |
| 6372 | { } |
| 6373 | }, |
| 6374 | }, |
| 6375 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { |
| 6376 | .type = ALC_FIXUP_FUNC, |
| 6377 | .v.func = alc271_hp_gate_mic_jack, |
| 6378 | .chained = true, |
| 6379 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
| 6380 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6381 | }; |
| 6382 | |
| 6383 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6384 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6385 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6386 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6387 | 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] | 6388 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6389 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6390 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6391 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6392 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6393 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6394 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6395 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6396 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6397 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6398 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6399 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6400 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6401 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6402 | 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] | 6403 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6404 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6405 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6406 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6407 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6408 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6409 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6410 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6411 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Stefán Freyr | 84f98fd | 2012-10-19 22:46:00 +0200 | [diff] [blame] | 6412 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6413 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6414 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6415 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6416 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6417 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6418 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6419 | /* Below is a quirk table taken from the old code. |
| 6420 | * Basically the device should work as is without the fixup table. |
| 6421 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6422 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6423 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6424 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6425 | ALC269_FIXUP_AMIC), |
| 6426 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6427 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6428 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6429 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6430 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6431 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6432 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6433 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6434 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6435 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6436 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6437 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6438 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6439 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6440 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6441 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6442 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6443 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6444 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6445 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6446 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6447 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6448 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6449 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6450 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6451 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6452 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6453 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6454 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6455 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6456 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6457 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6458 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6459 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6460 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6461 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6462 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6463 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6464 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6465 | #endif |
| 6466 | {} |
| 6467 | }; |
| 6468 | |
| 6469 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6470 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6471 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6472 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6473 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6474 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6475 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6476 | {} |
| 6477 | }; |
| 6478 | |
| 6479 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6480 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6481 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6482 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6483 | int val; |
| 6484 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6485 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6486 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6487 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6488 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6489 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6490 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6491 | } |
| 6492 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6493 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6494 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6495 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6496 | } |
| 6497 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6498 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6499 | val = alc_read_coef_idx(codec, 0x04); |
| 6500 | /* Power up output pin */ |
| 6501 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6502 | } |
| 6503 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6504 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6505 | val = alc_read_coef_idx(codec, 0xd); |
| 6506 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6507 | /* Capless ramp up clock control */ |
| 6508 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6509 | } |
| 6510 | val = alc_read_coef_idx(codec, 0x17); |
| 6511 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6512 | /* Class D power on reset */ |
| 6513 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6514 | } |
| 6515 | } |
| 6516 | |
| 6517 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6518 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6519 | |
| 6520 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6521 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6522 | } |
| 6523 | |
| 6524 | /* |
| 6525 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6526 | static int patch_alc269(struct hda_codec *codec) |
| 6527 | { |
| 6528 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6529 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6530 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6531 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6532 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6533 | return err; |
| 6534 | |
| 6535 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 6536 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6537 | |
Herton Ronaldo Krzesinski | 9f720bb | 2012-09-27 10:38:14 -0300 | [diff] [blame] | 6538 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6539 | alc269_fixup_tbl, alc269_fixups); |
| 6540 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6541 | |
| 6542 | alc_auto_parse_customize_define(codec); |
| 6543 | |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6544 | switch (codec->vendor_id) { |
| 6545 | case 0x10ec0269: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6546 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6547 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6548 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6549 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6550 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6551 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6552 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6553 | break; |
| 6554 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6555 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6556 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6557 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6558 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6559 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6560 | case 0x0030: |
| 6561 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6562 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6563 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6564 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6565 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6566 | if (err < 0) |
| 6567 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6568 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6569 | alc269_fill_coef(codec); |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6570 | break; |
| 6571 | |
| 6572 | case 0x10ec0280: |
| 6573 | case 0x10ec0290: |
| 6574 | spec->codec_variant = ALC269_TYPE_ALC280; |
| 6575 | break; |
| 6576 | case 0x10ec0282: |
| 6577 | case 0x10ec0283: |
| 6578 | spec->codec_variant = ALC269_TYPE_ALC282; |
| 6579 | break; |
| 6580 | case 0x10ec0284: |
| 6581 | case 0x10ec0292: |
| 6582 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 6583 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6584 | } |
| 6585 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6586 | /* automatic parse from the BIOS config */ |
| 6587 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6588 | if (err < 0) |
| 6589 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6590 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6591 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6592 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6593 | if (err < 0) |
| 6594 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6595 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6596 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6597 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6598 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6599 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6600 | codec->patch_ops.resume = alc269_resume; |
| 6601 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6602 | spec->shutup = alc269_shutup; |
| 6603 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6604 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6605 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6606 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6607 | |
| 6608 | error: |
| 6609 | alc_free(codec); |
| 6610 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6611 | } |
| 6612 | |
| 6613 | /* |
| 6614 | * ALC861 |
| 6615 | */ |
| 6616 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6617 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6618 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6619 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6620 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6621 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6622 | } |
| 6623 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6624 | /* Pin config fixes */ |
| 6625 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6626 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6627 | ALC861_FIXUP_AMP_VREF_0F, |
| 6628 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6629 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6630 | }; |
| 6631 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6632 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6633 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6634 | const struct alc_fixup *fix, int action) |
| 6635 | { |
| 6636 | struct alc_spec *spec = codec->spec; |
| 6637 | unsigned int val; |
| 6638 | |
| 6639 | if (action != ALC_FIXUP_ACT_INIT) |
| 6640 | return; |
| 6641 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6642 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6643 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6644 | val |= AC_PINCTL_IN_EN; |
| 6645 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6646 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6647 | spec->keep_vref_in_automute = 1; |
| 6648 | } |
| 6649 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6650 | /* suppress the jack-detection */ |
| 6651 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6652 | const struct alc_fixup *fix, int action) |
| 6653 | { |
| 6654 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6655 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6656 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6657 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6658 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6659 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6660 | .type = ALC_FIXUP_PINS, |
| 6661 | .v.pins = (const struct alc_pincfg[]) { |
| 6662 | { 0x0b, 0x0221101f }, /* HP */ |
| 6663 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6664 | { } |
| 6665 | } |
| 6666 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6667 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6668 | .type = ALC_FIXUP_FUNC, |
| 6669 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6670 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6671 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6672 | .type = ALC_FIXUP_FUNC, |
| 6673 | .v.func = alc_fixup_no_jack_detect, |
| 6674 | }, |
| 6675 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6676 | .type = ALC_FIXUP_FUNC, |
| 6677 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6678 | .chained = true, |
| 6679 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6680 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6681 | }; |
| 6682 | |
| 6683 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6684 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6685 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6686 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6687 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6688 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6689 | 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] | 6690 | {} |
| 6691 | }; |
| 6692 | |
| 6693 | /* |
| 6694 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6695 | static int patch_alc861(struct hda_codec *codec) |
| 6696 | { |
| 6697 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6698 | int err; |
| 6699 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6700 | err = alc_alloc_spec(codec, 0x15); |
| 6701 | if (err < 0) |
| 6702 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6703 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6704 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6705 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6706 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6707 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6708 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6709 | /* automatic parse from the BIOS config */ |
| 6710 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6711 | if (err < 0) |
| 6712 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6713 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6714 | if (!spec->no_analog) { |
| 6715 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6716 | if (err < 0) |
| 6717 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6718 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6719 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6720 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6721 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6722 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6723 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6724 | #endif |
| 6725 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6726 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6727 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6728 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6729 | |
| 6730 | error: |
| 6731 | alc_free(codec); |
| 6732 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6733 | } |
| 6734 | |
| 6735 | /* |
| 6736 | * ALC861-VD support |
| 6737 | * |
| 6738 | * Based on ALC882 |
| 6739 | * |
| 6740 | * In addition, an independent DAC |
| 6741 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6742 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6743 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6744 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6745 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6746 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6747 | } |
| 6748 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6749 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6750 | ALC660VD_FIX_ASUS_GPIO1, |
| 6751 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6752 | }; |
| 6753 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6754 | /* exclude VREF80 */ |
| 6755 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6756 | const struct alc_fixup *fix, int action) |
| 6757 | { |
| 6758 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | b78562b | 2012-12-17 20:06:49 +0100 | [diff] [blame] | 6759 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
| 6760 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6761 | } |
| 6762 | } |
| 6763 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6764 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6765 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6766 | .type = ALC_FIXUP_VERBS, |
| 6767 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6768 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6769 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6770 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6771 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6772 | { } |
| 6773 | } |
| 6774 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6775 | [ALC861VD_FIX_DALLAS] = { |
| 6776 | .type = ALC_FIXUP_FUNC, |
| 6777 | .v.func = alc861vd_fixup_dallas, |
| 6778 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6779 | }; |
| 6780 | |
| 6781 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6782 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6783 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6784 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6785 | {} |
| 6786 | }; |
| 6787 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6788 | /* |
| 6789 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6790 | static int patch_alc861vd(struct hda_codec *codec) |
| 6791 | { |
| 6792 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6793 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6794 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6795 | err = alc_alloc_spec(codec, 0x0b); |
| 6796 | if (err < 0) |
| 6797 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6798 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6799 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6800 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6801 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6802 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6803 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6804 | /* automatic parse from the BIOS config */ |
| 6805 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6806 | if (err < 0) |
| 6807 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6808 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6809 | if (!spec->no_analog) { |
| 6810 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6811 | if (err < 0) |
| 6812 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6813 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6814 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6815 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6816 | codec->patch_ops = alc_patch_ops; |
| 6817 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6818 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6819 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6820 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6821 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6822 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6823 | |
| 6824 | error: |
| 6825 | alc_free(codec); |
| 6826 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6827 | } |
| 6828 | |
| 6829 | /* |
| 6830 | * ALC662 support |
| 6831 | * |
| 6832 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6833 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6834 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6835 | * 6-channel independent captures. |
| 6836 | * |
| 6837 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6838 | * driver yet). |
| 6839 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6840 | |
| 6841 | /* |
| 6842 | * BIOS auto configuration |
| 6843 | */ |
| 6844 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6845 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6846 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6847 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6848 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6849 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6850 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6851 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6852 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6853 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6854 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6855 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6856 | ssids = alc662_ssids; |
| 6857 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6858 | } |
| 6859 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6860 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6861 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6862 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6863 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6864 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6865 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6866 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6867 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6868 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6869 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6870 | printk(KERN_WARNING |
| 6871 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6872 | } |
| 6873 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6874 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6875 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6876 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6877 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6878 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6879 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6880 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6881 | ALC662_FIXUP_ASUS_MODE1, |
| 6882 | ALC662_FIXUP_ASUS_MODE2, |
| 6883 | ALC662_FIXUP_ASUS_MODE3, |
| 6884 | ALC662_FIXUP_ASUS_MODE4, |
| 6885 | ALC662_FIXUP_ASUS_MODE5, |
| 6886 | ALC662_FIXUP_ASUS_MODE6, |
| 6887 | ALC662_FIXUP_ASUS_MODE7, |
| 6888 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6889 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6890 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6891 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6892 | }; |
| 6893 | |
| 6894 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6895 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6896 | .type = ALC_FIXUP_PINS, |
| 6897 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6898 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6899 | { } |
| 6900 | } |
| 6901 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6902 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6903 | .type = ALC_FIXUP_PINS, |
| 6904 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6905 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6906 | { } |
| 6907 | } |
| 6908 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6909 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6910 | .type = ALC_FIXUP_FUNC, |
| 6911 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6912 | }, |
| 6913 | [ALC662_FIXUP_CZC_P10T] = { |
| 6914 | .type = ALC_FIXUP_VERBS, |
| 6915 | .v.verbs = (const struct hda_verb[]) { |
| 6916 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6917 | {} |
| 6918 | } |
| 6919 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6920 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6921 | .type = ALC_FIXUP_FUNC, |
| 6922 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6923 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6924 | [ALC662_FIXUP_HP_RP5800] = { |
| 6925 | .type = ALC_FIXUP_PINS, |
| 6926 | .v.pins = (const struct alc_pincfg[]) { |
| 6927 | { 0x14, 0x0221201f }, /* HP out */ |
| 6928 | { } |
| 6929 | }, |
| 6930 | .chained = true, |
| 6931 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6932 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6933 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6934 | .type = ALC_FIXUP_PINS, |
| 6935 | .v.pins = (const struct alc_pincfg[]) { |
| 6936 | { 0x14, 0x99130110 }, /* speaker */ |
| 6937 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6938 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6939 | { 0x21, 0x0121401f }, /* HP out */ |
| 6940 | { } |
| 6941 | }, |
| 6942 | .chained = true, |
| 6943 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6944 | }, |
| 6945 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6946 | .type = ALC_FIXUP_PINS, |
| 6947 | .v.pins = (const struct alc_pincfg[]) { |
| 6948 | { 0x14, 0x99130110 }, /* speaker */ |
| 6949 | { 0x18, 0x01a19820 }, /* mic */ |
| 6950 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6951 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6952 | { } |
| 6953 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6954 | .chained = true, |
| 6955 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6956 | }, |
| 6957 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6958 | .type = ALC_FIXUP_PINS, |
| 6959 | .v.pins = (const struct alc_pincfg[]) { |
| 6960 | { 0x14, 0x99130110 }, /* speaker */ |
| 6961 | { 0x15, 0x0121441f }, /* HP */ |
| 6962 | { 0x18, 0x01a19840 }, /* mic */ |
| 6963 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6964 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6965 | { } |
| 6966 | }, |
| 6967 | .chained = true, |
| 6968 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6969 | }, |
| 6970 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6971 | .type = ALC_FIXUP_PINS, |
| 6972 | .v.pins = (const struct alc_pincfg[]) { |
| 6973 | { 0x14, 0x99130110 }, /* speaker */ |
| 6974 | { 0x16, 0x99130111 }, /* speaker */ |
| 6975 | { 0x18, 0x01a19840 }, /* mic */ |
| 6976 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6977 | { 0x21, 0x0121441f }, /* HP */ |
| 6978 | { } |
| 6979 | }, |
| 6980 | .chained = true, |
| 6981 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6982 | }, |
| 6983 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6984 | .type = ALC_FIXUP_PINS, |
| 6985 | .v.pins = (const struct alc_pincfg[]) { |
| 6986 | { 0x14, 0x99130110 }, /* speaker */ |
| 6987 | { 0x15, 0x0121441f }, /* HP */ |
| 6988 | { 0x16, 0x99130111 }, /* speaker */ |
| 6989 | { 0x18, 0x01a19840 }, /* mic */ |
| 6990 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6991 | { } |
| 6992 | }, |
| 6993 | .chained = true, |
| 6994 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6995 | }, |
| 6996 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6997 | .type = ALC_FIXUP_PINS, |
| 6998 | .v.pins = (const struct alc_pincfg[]) { |
| 6999 | { 0x14, 0x99130110 }, /* speaker */ |
| 7000 | { 0x15, 0x01211420 }, /* HP2 */ |
| 7001 | { 0x18, 0x01a19840 }, /* mic */ |
| 7002 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7003 | { 0x1b, 0x0121441f }, /* HP */ |
| 7004 | { } |
| 7005 | }, |
| 7006 | .chained = true, |
| 7007 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7008 | }, |
| 7009 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 7010 | .type = ALC_FIXUP_PINS, |
| 7011 | .v.pins = (const struct alc_pincfg[]) { |
| 7012 | { 0x14, 0x99130110 }, /* speaker */ |
| 7013 | { 0x17, 0x99130111 }, /* speaker */ |
| 7014 | { 0x18, 0x01a19840 }, /* mic */ |
| 7015 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7016 | { 0x1b, 0x01214020 }, /* HP */ |
| 7017 | { 0x21, 0x0121401f }, /* HP */ |
| 7018 | { } |
| 7019 | }, |
| 7020 | .chained = true, |
| 7021 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7022 | }, |
| 7023 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 7024 | .type = ALC_FIXUP_PINS, |
| 7025 | .v.pins = (const struct alc_pincfg[]) { |
| 7026 | { 0x14, 0x99130110 }, /* speaker */ |
| 7027 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 7028 | { 0x15, 0x01214020 }, /* HP */ |
| 7029 | { 0x17, 0x99130111 }, /* speaker */ |
| 7030 | { 0x18, 0x01a19840 }, /* mic */ |
| 7031 | { 0x21, 0x0121401f }, /* HP */ |
| 7032 | { } |
| 7033 | }, |
| 7034 | .chained = true, |
| 7035 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7036 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7037 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 7038 | .type = ALC_FIXUP_FUNC, |
| 7039 | .v.func = alc_fixup_no_jack_detect, |
| 7040 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7041 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 7042 | .type = ALC_FIXUP_PINS, |
| 7043 | .v.pins = (const struct alc_pincfg[]) { |
| 7044 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 7045 | { } |
| 7046 | } |
| 7047 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7048 | [ALC662_FIXUP_INV_DMIC] = { |
| 7049 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7050 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7051 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7052 | }; |
| 7053 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7054 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7055 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 7056 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7057 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7058 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7059 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7060 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7061 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7062 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 7063 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 7064 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7065 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7066 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7067 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7068 | |
| 7069 | #if 0 |
| 7070 | /* Below is a quirk table taken from the old code. |
| 7071 | * Basically the device should work as is without the fixup table. |
| 7072 | * If BIOS doesn't give a proper info, enable the corresponding |
| 7073 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 7074 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7075 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 7076 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 7077 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 7078 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 7079 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7080 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7081 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7082 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 7083 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 7084 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7085 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 7086 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 7087 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 7088 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 7089 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 7090 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7091 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 7092 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 7093 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7094 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7095 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7096 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7097 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 7098 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 7099 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 7100 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7101 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 7102 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7103 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7104 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 7105 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7106 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7107 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 7108 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 7109 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 7110 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 7111 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 7112 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 7113 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 7114 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7115 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 7116 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 7117 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7118 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 7119 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 7120 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 7121 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 7122 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 7123 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7124 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 7125 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7126 | {} |
| 7127 | }; |
| 7128 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7129 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 7130 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7131 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 7132 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 7133 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 7134 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 7135 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 7136 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 7137 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 7138 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7139 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7140 | {} |
| 7141 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7142 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7143 | static void alc662_fill_coef(struct hda_codec *codec) |
| 7144 | { |
| 7145 | int val, coef; |
| 7146 | |
| 7147 | coef = alc_get_coef0(codec); |
| 7148 | |
| 7149 | switch (codec->vendor_id) { |
| 7150 | case 0x10ec0662: |
| 7151 | if ((coef & 0x00f0) == 0x0030) { |
| 7152 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 7153 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 7154 | } |
| 7155 | break; |
| 7156 | case 0x10ec0272: |
| 7157 | case 0x10ec0273: |
| 7158 | case 0x10ec0663: |
| 7159 | case 0x10ec0665: |
| 7160 | case 0x10ec0670: |
| 7161 | case 0x10ec0671: |
| 7162 | case 0x10ec0672: |
| 7163 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 7164 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 7165 | break; |
| 7166 | } |
| 7167 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7168 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7169 | /* |
| 7170 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7171 | static int patch_alc662(struct hda_codec *codec) |
| 7172 | { |
| 7173 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7174 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7175 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7176 | err = alc_alloc_spec(codec, 0x0b); |
| 7177 | if (err < 0) |
| 7178 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7179 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7180 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7181 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7182 | /* handle multiple HPs as is */ |
| 7183 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 7184 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 7185 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 7186 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7187 | spec->init_hook = alc662_fill_coef; |
| 7188 | alc662_fill_coef(codec); |
| 7189 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 7190 | alc_pick_fixup(codec, alc662_fixup_models, |
| 7191 | alc662_fixup_tbl, alc662_fixups); |
| 7192 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 7193 | |
| 7194 | alc_auto_parse_customize_define(codec); |
| 7195 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 7196 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7197 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 7198 | spec->cdefine.platform_type == 1) { |
| 7199 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 7200 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 7201 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7202 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 7203 | /* automatic parse from the BIOS config */ |
| 7204 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7205 | if (err < 0) |
| 7206 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7207 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7208 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 7209 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7210 | if (err < 0) |
| 7211 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 7212 | switch (codec->vendor_id) { |
| 7213 | case 0x10ec0662: |
| 7214 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 7215 | break; |
| 7216 | case 0x10ec0272: |
| 7217 | case 0x10ec0663: |
| 7218 | case 0x10ec0665: |
| 7219 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 7220 | break; |
| 7221 | case 0x10ec0273: |
| 7222 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 7223 | break; |
| 7224 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7225 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 7226 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7227 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 7228 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7229 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 7230 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 7231 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7232 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7233 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7234 | error: |
| 7235 | alc_free(codec); |
| 7236 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 7237 | } |
| 7238 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7239 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7240 | * ALC680 support |
| 7241 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7242 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7243 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7244 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7245 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7246 | } |
| 7247 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7248 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7249 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7250 | static int patch_alc680(struct hda_codec *codec) |
| 7251 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7252 | int err; |
| 7253 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7254 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7255 | err = alc_alloc_spec(codec, 0); |
| 7256 | if (err < 0) |
| 7257 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7258 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7259 | /* automatic parse from the BIOS config */ |
| 7260 | err = alc680_parse_auto_config(codec); |
| 7261 | if (err < 0) { |
| 7262 | alc_free(codec); |
| 7263 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7264 | } |
| 7265 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7266 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7267 | |
| 7268 | return 0; |
| 7269 | } |
| 7270 | |
| 7271 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7272 | * patch entries |
| 7273 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7274 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7275 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7276 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7277 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7278 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7279 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7280 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7281 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7282 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7283 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7284 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7285 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7286 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7287 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 7288 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7289 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
David Henningsson | af02dde | 2012-11-21 08:57:58 +0100 | [diff] [blame] | 7290 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7291 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7292 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7293 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7294 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7295 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7296 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7297 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7298 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7299 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7300 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7301 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7302 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7303 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7304 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7305 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7306 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7307 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7308 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7309 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7310 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7311 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7312 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7313 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7314 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7315 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7316 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7317 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7318 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7319 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7320 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7321 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7322 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7323 | {} /* terminator */ |
| 7324 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7325 | |
| 7326 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7327 | |
| 7328 | MODULE_LICENSE("GPL"); |
| 7329 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7330 | |
| 7331 | static struct hda_codec_preset_list realtek_list = { |
| 7332 | .preset = snd_hda_preset_realtek, |
| 7333 | .owner = THIS_MODULE, |
| 7334 | }; |
| 7335 | |
| 7336 | static int __init patch_realtek_init(void) |
| 7337 | { |
| 7338 | return snd_hda_add_codec_preset(&realtek_list); |
| 7339 | } |
| 7340 | |
| 7341 | static void __exit patch_realtek_exit(void) |
| 7342 | { |
| 7343 | snd_hda_delete_codec_preset(&realtek_list); |
| 7344 | } |
| 7345 | |
| 7346 | module_init(patch_realtek_init) |
| 7347 | module_exit(patch_realtek_exit) |