Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4 | * HD audio interface patch for Realtek ALC codecs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 409a3e9 | 2012-03-27 13:01:01 +1030 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@just42.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 32 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 35 | #include "hda_auto_parser.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 36 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 37 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 39 | /* unsol event tags */ |
| 40 | #define ALC_FRONT_EVENT 0x01 |
| 41 | #define ALC_DCVOL_EVENT 0x02 |
| 42 | #define ALC_HP_EVENT 0x04 |
| 43 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 44 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 45 | /* for GPIO Poll */ |
| 46 | #define GPIO_MASK 0x03 |
| 47 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 48 | /* extra amp-initialization sequence types */ |
| 49 | enum { |
| 50 | ALC_INIT_NONE, |
| 51 | ALC_INIT_DEFAULT, |
| 52 | ALC_INIT_GPIO1, |
| 53 | ALC_INIT_GPIO2, |
| 54 | ALC_INIT_GPIO3, |
| 55 | }; |
| 56 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 57 | struct alc_customize_define { |
| 58 | unsigned int sku_cfg; |
| 59 | unsigned char port_connectivity; |
| 60 | unsigned char check_sum; |
| 61 | unsigned char customization; |
| 62 | unsigned char external_amp; |
| 63 | unsigned int enable_pcbeep:1; |
| 64 | unsigned int platform_type:1; |
| 65 | unsigned int swap:1; |
| 66 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 67 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 70 | struct alc_multi_io { |
| 71 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 72 | hda_nid_t dac; /* DAC to be connected */ |
| 73 | unsigned int ctl_in; /* cached input-pin control value */ |
| 74 | }; |
| 75 | |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 76 | #define MAX_VOL_NIDS 0x40 |
| 77 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 78 | /* make compatible with old code */ |
| 79 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 80 | #define alc_apply_fixup snd_hda_apply_fixup |
| 81 | #define alc_pick_fixup snd_hda_pick_fixup |
| 82 | #define alc_fixup hda_fixup |
| 83 | #define alc_pincfg hda_pintbl |
| 84 | #define alc_model_fixup hda_model_fixup |
| 85 | |
| 86 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 87 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 88 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 89 | |
| 90 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 91 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 92 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 93 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 94 | |
| 95 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 96 | #define MAX_NID_PATH_DEPTH 5 |
| 97 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 98 | /* Widget connection path |
| 99 | * |
| 100 | * For output, stored in the order of DAC -> ... -> pin, |
| 101 | * for input, pin -> ... -> ADC. |
| 102 | * |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 103 | * idx[i] contains the source index number to select on of the widget path[i]; |
| 104 | * 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] | 105 | * multi[] indicates whether it's a selector widget with multi-connectors |
| 106 | * (i.e. the connection selection is mandatory) |
| 107 | * vol_ctl and mute_ctl contains the NIDs for the assigned mixers |
| 108 | */ |
| 109 | struct nid_path { |
| 110 | int depth; |
| 111 | hda_nid_t path[MAX_NID_PATH_DEPTH]; |
| 112 | unsigned char idx[MAX_NID_PATH_DEPTH]; |
| 113 | unsigned char multi[MAX_NID_PATH_DEPTH]; |
| 114 | unsigned int ctls[2]; /* 0 = volume, 1 = mute */ |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 115 | bool active; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 116 | }; |
| 117 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 118 | enum { NID_PATH_VOL_CTL = 0, NID_PATH_MUTE_CTL = 1 }; |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | struct alc_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 121 | struct hda_gen_spec gen; |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 124 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 126 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
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 | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 150 | const hda_nid_t *adc_nids; |
| 151 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 152 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 153 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 155 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 156 | hda_nid_t cur_adc; |
| 157 | unsigned int cur_adc_stream_tag; |
| 158 | unsigned int cur_adc_format; |
| 159 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 161 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | const struct hda_input_mux *input_mux; |
| 163 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 164 | hda_nid_t ext_mic_pin; |
| 165 | hda_nid_t dock_mic_pin; |
| 166 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
| 168 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 169 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 171 | int need_dac_fix; |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 172 | int const_channel_count; /* min. channel count (for speakers) */ |
| 173 | int ext_channel_count; /* current channel count for multi-io */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 176 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 177 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 178 | /* dynamic controls, init_verbs and input_mux */ |
| 179 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 180 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 181 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 182 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 183 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 184 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 185 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 186 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 187 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 188 | int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 189 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 190 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 191 | /* DAC list */ |
| 192 | int num_all_dacs; |
| 193 | hda_nid_t all_dacs[16]; |
| 194 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 195 | /* path list */ |
| 196 | struct snd_array paths; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 197 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 198 | /* hooks */ |
| 199 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 200 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 201 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 202 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 203 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 204 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 205 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 206 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 207 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 208 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 209 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 210 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 211 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 212 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 213 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 214 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 215 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 216 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 217 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 218 | 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] | 219 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 220 | /* other flags */ |
| 221 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 222 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 223 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 224 | unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 225 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 226 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 227 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 228 | 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] | 229 | unsigned int no_primary_hp:1; /* Don't prefer HP pins to speaker pins */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 230 | |
| 231 | /* auto-mute control */ |
| 232 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 233 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 234 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 235 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 236 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 237 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 238 | /* for virtual master */ |
| 239 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 240 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 241 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 242 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 243 | int num_loopbacks; |
| 244 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 245 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 246 | |
| 247 | /* for PLL fix */ |
| 248 | hda_nid_t pll_nid; |
| 249 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 250 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 251 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 252 | /* multi-io */ |
| 253 | int multi_ios; |
| 254 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 255 | |
| 256 | /* bind volumes */ |
| 257 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 258 | }; |
| 259 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 260 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 261 | int dir, unsigned int bits) |
| 262 | { |
| 263 | if (!nid) |
| 264 | return false; |
| 265 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 266 | if (query_amp_caps(codec, nid, dir) & bits) |
| 267 | return true; |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | #define nid_has_mute(codec, nid, dir) \ |
| 272 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 273 | #define nid_has_volume(codec, nid, dir) \ |
| 274 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* |
| 277 | * input MUX handling |
| 278 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 279 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 280 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { |
| 282 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 283 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 284 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 285 | if (mux_idx >= spec->num_mux_defs) |
| 286 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 287 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 288 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 289 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 292 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 293 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | { |
| 295 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 296 | struct alc_spec *spec = codec->spec; |
| 297 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 298 | |
| 299 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 300 | return 0; |
| 301 | } |
| 302 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 303 | 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] | 304 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 305 | struct alc_spec *spec = codec->spec; |
| 306 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 307 | |
| 308 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 309 | /* stream is running, let's swap the current ADC */ |
| 310 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 311 | spec->cur_adc = new_adc; |
| 312 | snd_hda_codec_setup_stream(codec, new_adc, |
| 313 | spec->cur_adc_stream_tag, 0, |
| 314 | spec->cur_adc_format); |
| 315 | return true; |
| 316 | } |
| 317 | return false; |
| 318 | } |
| 319 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 320 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 321 | { |
| 322 | return spec->capsrc_nids ? |
| 323 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 324 | } |
| 325 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 326 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 327 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 328 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 329 | /* for shared I/O, change the pin-control accordingly */ |
| 330 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 331 | { |
| 332 | struct alc_spec *spec = codec->spec; |
| 333 | unsigned int val; |
| 334 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 335 | /* NOTE: this assumes that there are only two inputs, the |
| 336 | * first is the real internal mic and the second is HP/mic jack. |
| 337 | */ |
| 338 | |
| 339 | val = snd_hda_get_default_vref(codec, pin); |
| 340 | |
| 341 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 342 | instead, as suggested by Realtek */ |
| 343 | if (val == AC_PINCTL_VREF_HIZ) { |
| 344 | const hda_nid_t vref_pin = 0x18; |
| 345 | /* Sanity check pin 0x18 */ |
| 346 | if (get_wcaps_type(get_wcaps(codec, vref_pin)) == AC_WID_PIN && |
| 347 | get_defcfg_connect(snd_hda_codec_get_pincfg(codec, vref_pin)) == AC_JACK_PORT_NONE) { |
| 348 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 349 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 350 | snd_hda_set_pin_ctl(codec, vref_pin, PIN_IN | (set_as_mic ? vref_val : 0)); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 355 | snd_hda_set_pin_ctl(codec, pin, val); |
| 356 | |
| 357 | spec->automute_speaker = !set_as_mic; |
| 358 | call_update_outputs(codec); |
| 359 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 360 | |
| 361 | /* select the given imux item; either unmute exclusively or select the route */ |
| 362 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 363 | unsigned int idx, bool force) |
| 364 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 366 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 367 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 368 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 369 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
Takashi Iwai | 5803a32 | 2012-02-21 11:59:45 +0100 | [diff] [blame] | 371 | if (!spec->input_mux) |
| 372 | return 0; |
| 373 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 374 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 375 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 376 | if (!imux->num_items && mux_idx > 0) |
| 377 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 378 | if (!imux->num_items) |
| 379 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 380 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 381 | if (idx >= imux->num_items) |
| 382 | idx = imux->num_items - 1; |
| 383 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 384 | return 0; |
| 385 | spec->cur_mux[adc_idx] = idx; |
| 386 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 387 | if (spec->shared_mic_hp) |
| 388 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 389 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 390 | if (spec->dyn_adc_switch) { |
| 391 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 392 | adc_idx = spec->dyn_adc_idx[idx]; |
| 393 | } |
| 394 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 395 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 396 | |
| 397 | /* no selection? */ |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 398 | num_conns = snd_hda_get_num_conns(codec, nid); |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 399 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 400 | return 1; |
| 401 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 402 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 403 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 404 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 405 | int active = imux->items[idx].index; |
| 406 | for (i = 0; i < num_conns; i++) { |
| 407 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 408 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 409 | HDA_AMP_MUTE, v); |
| 410 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 411 | } else { |
| 412 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 413 | snd_hda_codec_write_cache(codec, nid, 0, |
| 414 | AC_VERB_SET_CONNECT_SEL, |
| 415 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 416 | } |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 417 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 418 | return 1; |
| 419 | } |
| 420 | |
| 421 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 422 | struct snd_ctl_elem_value *ucontrol) |
| 423 | { |
| 424 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 425 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 426 | return alc_mux_select(codec, adc_idx, |
| 427 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 428 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 429 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 431 | * set up the input pin config (depending on the given auto-pin type) |
| 432 | */ |
| 433 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 434 | int auto_pin_type) |
| 435 | { |
| 436 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 437 | if (auto_pin_type == AUTO_PIN_MIC) |
| 438 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 439 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 443 | * Append the given mixer and verb elements for the later use |
| 444 | * The mixer array is referred in build_controls(), and init_verbs are |
| 445 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 446 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 447 | 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] | 448 | { |
| 449 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 450 | return; |
| 451 | spec->mixers[spec->num_mixers++] = mix; |
| 452 | } |
| 453 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 454 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 455 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 456 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 457 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 458 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 459 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 460 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 461 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 462 | { } |
| 463 | }; |
| 464 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 465 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 466 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 467 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 468 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 469 | { } |
| 470 | }; |
| 471 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 472 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 473 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 474 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 475 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 476 | { } |
| 477 | }; |
| 478 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 479 | /* |
| 480 | * Fix hardware PLL issue |
| 481 | * On some codecs, the analog PLL gating control must be off while |
| 482 | * the default value is 1. |
| 483 | */ |
| 484 | static void alc_fix_pll(struct hda_codec *codec) |
| 485 | { |
| 486 | struct alc_spec *spec = codec->spec; |
| 487 | unsigned int val; |
| 488 | |
| 489 | if (!spec->pll_nid) |
| 490 | return; |
| 491 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 492 | spec->pll_coef_idx); |
| 493 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 494 | AC_VERB_GET_PROC_COEF, 0); |
| 495 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 496 | spec->pll_coef_idx); |
| 497 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 498 | val & ~(1 << spec->pll_coef_bit)); |
| 499 | } |
| 500 | |
| 501 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 502 | unsigned int coef_idx, unsigned int coef_bit) |
| 503 | { |
| 504 | struct alc_spec *spec = codec->spec; |
| 505 | spec->pll_nid = nid; |
| 506 | spec->pll_coef_idx = coef_idx; |
| 507 | spec->pll_coef_bit = coef_bit; |
| 508 | alc_fix_pll(codec); |
| 509 | } |
| 510 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 511 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 512 | * Jack detections for HP auto-mute and mic-switch |
| 513 | */ |
| 514 | |
| 515 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 516 | 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] | 517 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 518 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 519 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 520 | for (i = 0; i < num_pins; i++) { |
| 521 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 522 | if (!nid) |
| 523 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 524 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 525 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 526 | return present; |
| 527 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 528 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 529 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 530 | 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] | 531 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 532 | { |
| 533 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 534 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 535 | int i; |
| 536 | |
| 537 | for (i = 0; i < num_pins; i++) { |
| 538 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 539 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 540 | if (!nid) |
| 541 | break; |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 542 | /* don't reset VREF value in case it's controlling |
| 543 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 544 | */ |
| 545 | if (spec->keep_vref_in_automute) { |
| 546 | val = snd_hda_codec_read(codec, nid, 0, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 547 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 548 | val &= ~PIN_HP; |
| 549 | } else |
| 550 | val = 0; |
| 551 | val |= pin_bits; |
| 552 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 553 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 554 | } |
| 555 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 556 | /* Toggle outputs muting */ |
| 557 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 558 | { |
| 559 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 560 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 561 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 562 | /* Control HP pins/amps depending on master_mute state; |
| 563 | * in general, HP pins/amps control should be enabled in all cases, |
| 564 | * but currently set only for master_mute, just to be safe |
| 565 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 566 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 567 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 568 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 569 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 570 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 571 | on = 0; |
| 572 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 573 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 574 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 575 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 576 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 577 | |
| 578 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 579 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 580 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 581 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 582 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 583 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 584 | on = 0; |
| 585 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 586 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 587 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 588 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 589 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 590 | } |
| 591 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 592 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 593 | { |
| 594 | struct alc_spec *spec = codec->spec; |
| 595 | if (spec->automute_hook) |
| 596 | spec->automute_hook(codec); |
| 597 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 598 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 599 | } |
| 600 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 601 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 602 | 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] | 603 | { |
| 604 | struct alc_spec *spec = codec->spec; |
| 605 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 606 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 607 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 608 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 609 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 610 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 611 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 612 | } |
| 613 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 614 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 615 | 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] | 616 | { |
| 617 | struct alc_spec *spec = codec->spec; |
| 618 | |
David Henningsson | f7f4b232 | 2012-10-10 16:32:09 +0200 | [diff] [blame] | 619 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 620 | return; |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 621 | /* check LO jack only when it's different from HP */ |
| 622 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 623 | return; |
| 624 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 625 | spec->line_jack_present = |
| 626 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 627 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 628 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 629 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 630 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 631 | } |
| 632 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 633 | #define get_connection_index(codec, mux, nid) \ |
| 634 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 635 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 636 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 637 | 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] | 638 | { |
| 639 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 640 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 641 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 642 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 643 | return; |
| 644 | if (snd_BUG_ON(!spec->adc_nids)) |
| 645 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 646 | 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] | 647 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 648 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 649 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 650 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 651 | else if (spec->dock_mic_idx >= 0 && |
| 652 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 653 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 654 | else |
| 655 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 656 | } |
| 657 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 658 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 659 | 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] | 660 | { |
| 661 | unsigned int val; |
| 662 | struct snd_kcontrol *kctl; |
| 663 | struct snd_ctl_elem_value *uctl; |
| 664 | |
| 665 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 666 | if (!kctl) |
| 667 | return; |
| 668 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 669 | if (!uctl) |
| 670 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 671 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 672 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 673 | val &= HDA_AMP_VOLMASK; |
| 674 | uctl->value.integer.value[0] = val; |
| 675 | uctl->value.integer.value[1] = val; |
| 676 | kctl->put(kctl, uctl); |
| 677 | kfree(uctl); |
| 678 | } |
| 679 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 680 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 681 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 682 | /* For some reason, the res given from ALC880 is broken. |
| 683 | Here we adjust it properly. */ |
| 684 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 685 | } |
| 686 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 687 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 688 | static void alc_inithook(struct hda_codec *codec) |
| 689 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 690 | alc_hp_automute(codec, NULL); |
| 691 | alc_line_automute(codec, NULL); |
| 692 | alc_mic_automute(codec, NULL); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 693 | } |
| 694 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 695 | /* additional initialization for ALC888 variants */ |
| 696 | static void alc888_coef_init(struct hda_codec *codec) |
| 697 | { |
| 698 | unsigned int tmp; |
| 699 | |
| 700 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 701 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 702 | 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] | 703 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 704 | /* alc888S-VC */ |
| 705 | snd_hda_codec_read(codec, 0x20, 0, |
| 706 | AC_VERB_SET_PROC_COEF, 0x830); |
| 707 | else |
| 708 | /* alc888-VB */ |
| 709 | snd_hda_codec_read(codec, 0x20, 0, |
| 710 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 711 | } |
| 712 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 713 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 714 | static void alc889_coef_init(struct hda_codec *codec) |
| 715 | { |
| 716 | unsigned int tmp; |
| 717 | |
| 718 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 719 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 720 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 721 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 722 | } |
| 723 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 724 | /* turn on/off EAPD control (only if available) */ |
| 725 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 726 | { |
| 727 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 728 | return; |
| 729 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 730 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 731 | on ? 2 : 0); |
| 732 | } |
| 733 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 734 | /* turn on/off EAPD controls of the codec */ |
| 735 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 736 | { |
| 737 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 738 | static hda_nid_t pins[] = { |
| 739 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 740 | }; |
| 741 | hda_nid_t *p; |
| 742 | for (p = pins; *p; p++) |
| 743 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 744 | } |
| 745 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 746 | /* generic shutup callback; |
| 747 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 748 | */ |
| 749 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 750 | { |
| 751 | alc_auto_setup_eapd(codec, false); |
| 752 | msleep(200); |
| 753 | } |
| 754 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 755 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 756 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 757 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 758 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 759 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 760 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 761 | switch (type) { |
| 762 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 763 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 764 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 765 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 766 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 767 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 768 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 769 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 770 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 771 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 772 | switch (codec->vendor_id) { |
| 773 | case 0x10ec0260: |
| 774 | snd_hda_codec_write(codec, 0x1a, 0, |
| 775 | AC_VERB_SET_COEF_INDEX, 7); |
| 776 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 777 | AC_VERB_GET_PROC_COEF, 0); |
| 778 | snd_hda_codec_write(codec, 0x1a, 0, |
| 779 | AC_VERB_SET_COEF_INDEX, 7); |
| 780 | snd_hda_codec_write(codec, 0x1a, 0, |
| 781 | AC_VERB_SET_PROC_COEF, |
| 782 | tmp | 0x2010); |
| 783 | break; |
| 784 | case 0x10ec0262: |
| 785 | case 0x10ec0880: |
| 786 | case 0x10ec0882: |
| 787 | case 0x10ec0883: |
| 788 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 789 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 790 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 791 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 792 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 793 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 794 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 795 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 796 | #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] | 797 | case 0x10ec0267: |
| 798 | case 0x10ec0268: |
| 799 | snd_hda_codec_write(codec, 0x20, 0, |
| 800 | AC_VERB_SET_COEF_INDEX, 7); |
| 801 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 802 | AC_VERB_GET_PROC_COEF, 0); |
| 803 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 804 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 805 | snd_hda_codec_write(codec, 0x20, 0, |
| 806 | AC_VERB_SET_PROC_COEF, |
| 807 | tmp | 0x3000); |
| 808 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 809 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 810 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 811 | break; |
| 812 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 813 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 814 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 815 | /* |
| 816 | * Auto-Mute mode mixer enum support |
| 817 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 818 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 819 | struct snd_ctl_elem_info *uinfo) |
| 820 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 821 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 822 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 823 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 824 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 825 | }; |
| 826 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 827 | if (spec->automute_speaker_possible && spec->automute_lo_possible) |
| 828 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 829 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 833 | struct snd_ctl_elem_value *ucontrol) |
| 834 | { |
| 835 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 836 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 837 | unsigned int val = 0; |
| 838 | if (spec->automute_speaker) |
| 839 | val++; |
| 840 | if (spec->automute_lo) |
| 841 | val++; |
| 842 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 843 | ucontrol->value.enumerated.item[0] = val; |
| 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 848 | struct snd_ctl_elem_value *ucontrol) |
| 849 | { |
| 850 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 851 | struct alc_spec *spec = codec->spec; |
| 852 | |
| 853 | switch (ucontrol->value.enumerated.item[0]) { |
| 854 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 855 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 856 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 857 | spec->automute_speaker = 0; |
| 858 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 859 | break; |
| 860 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 861 | if (spec->automute_speaker_possible) { |
| 862 | if (!spec->automute_lo && spec->automute_speaker) |
| 863 | return 0; |
| 864 | spec->automute_speaker = 1; |
| 865 | spec->automute_lo = 0; |
| 866 | } else if (spec->automute_lo_possible) { |
| 867 | if (spec->automute_lo) |
| 868 | return 0; |
| 869 | spec->automute_lo = 1; |
| 870 | } else |
| 871 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 872 | break; |
| 873 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 874 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 875 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 876 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 877 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 878 | spec->automute_speaker = 1; |
| 879 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 880 | break; |
| 881 | default: |
| 882 | return -EINVAL; |
| 883 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 884 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 885 | return 1; |
| 886 | } |
| 887 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 888 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 889 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 890 | .name = "Auto-Mute Mode", |
| 891 | .info = alc_automute_mode_info, |
| 892 | .get = alc_automute_mode_get, |
| 893 | .put = alc_automute_mode_put, |
| 894 | }; |
| 895 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 896 | static struct snd_kcontrol_new * |
| 897 | alc_kcontrol_new(struct alc_spec *spec, const char *name, |
| 898 | const struct snd_kcontrol_new *temp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 899 | { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 900 | struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); |
| 901 | if (!knew) |
| 902 | return NULL; |
| 903 | *knew = *temp; |
| 904 | knew->name = kstrdup(name, GFP_KERNEL); |
| 905 | if (!knew->name) |
| 906 | return NULL; |
| 907 | return knew; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 908 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 909 | |
| 910 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 911 | { |
| 912 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 913 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 914 | if (!alc_kcontrol_new(spec, "Auto-Mute Mode", &alc_automute_mode_enum)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 915 | return -ENOMEM; |
| 916 | return 0; |
| 917 | } |
| 918 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 919 | /* |
| 920 | * Check the availability of HP/line-out auto-mute; |
| 921 | * Set up appropriately if really supported |
| 922 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 923 | static int alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 924 | { |
| 925 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 926 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 927 | int present = 0; |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 928 | int i, err; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 929 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 930 | if (cfg->hp_pins[0]) |
| 931 | present++; |
| 932 | if (cfg->line_out_pins[0]) |
| 933 | present++; |
| 934 | if (cfg->speaker_pins[0]) |
| 935 | present++; |
| 936 | if (present < 2) /* need two different output types */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 937 | return 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 938 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 939 | if (!cfg->speaker_pins[0] && |
| 940 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 941 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 942 | sizeof(cfg->speaker_pins)); |
| 943 | cfg->speaker_outs = cfg->line_outs; |
| 944 | } |
| 945 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 946 | if (!cfg->hp_pins[0] && |
| 947 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 948 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 949 | sizeof(cfg->hp_pins)); |
| 950 | cfg->hp_outs = cfg->line_outs; |
| 951 | } |
| 952 | |
| 953 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 954 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 955 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 956 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 957 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 958 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 959 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 960 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 961 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 962 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 963 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 964 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 965 | if (cfg->speaker_outs) |
| 966 | for (i = 0; i < cfg->line_outs; i++) { |
| 967 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 968 | if (!is_jack_detectable(codec, nid)) |
| 969 | continue; |
| 970 | snd_printdd("realtek: Enable Line-Out " |
| 971 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 972 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 973 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 974 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 975 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 976 | spec->automute_lo_possible = spec->detect_hp; |
| 977 | } |
| 978 | |
| 979 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 980 | (spec->detect_hp || spec->detect_lo); |
| 981 | |
| 982 | spec->automute_lo = spec->automute_lo_possible; |
| 983 | spec->automute_speaker = spec->automute_speaker_possible; |
| 984 | |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 985 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 986 | /* create a control for automute mode */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 987 | err = alc_add_automute_mode_enum(codec); |
| 988 | if (err < 0) |
| 989 | return err; |
| 990 | } |
| 991 | return 0; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 992 | } |
| 993 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 994 | /* 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] | 995 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 996 | { |
| 997 | int i; |
| 998 | for (i = 0; i < nums; i++) |
| 999 | if (list[i] == nid) |
| 1000 | return i; |
| 1001 | return -1; |
| 1002 | } |
| 1003 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1004 | /* check whether dynamic ADC-switching is available */ |
| 1005 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 1006 | { |
| 1007 | struct alc_spec *spec = codec->spec; |
| 1008 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 1009 | int i, n, idx; |
| 1010 | hda_nid_t cap, pin; |
| 1011 | |
| 1012 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1013 | return false; |
| 1014 | |
| 1015 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1016 | cap = spec->private_capsrc_nids[n]; |
| 1017 | for (i = 0; i < imux->num_items; i++) { |
| 1018 | pin = spec->imux_pins[i]; |
| 1019 | if (!pin) |
| 1020 | return false; |
| 1021 | if (get_connection_index(codec, cap, pin) < 0) |
| 1022 | break; |
| 1023 | } |
| 1024 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1025 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | for (i = 0; i < imux->num_items; i++) { |
| 1029 | pin = spec->imux_pins[i]; |
| 1030 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1031 | cap = spec->private_capsrc_nids[n]; |
| 1032 | idx = get_connection_index(codec, cap, pin); |
| 1033 | if (idx >= 0) { |
| 1034 | imux->items[i].index = idx; |
| 1035 | spec->dyn_adc_idx[i] = n; |
| 1036 | break; |
| 1037 | } |
| 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1042 | spec->dyn_adc_switch = 1; |
| 1043 | return true; |
| 1044 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1045 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1046 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1047 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1048 | { |
| 1049 | struct alc_spec *spec = codec->spec; |
| 1050 | const struct hda_input_mux *imux; |
| 1051 | |
| 1052 | if (!spec->auto_mic) |
| 1053 | return false; |
| 1054 | if (spec->auto_mic_valid_imux) |
| 1055 | return true; /* already checked */ |
| 1056 | |
| 1057 | /* fill up imux indices */ |
| 1058 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1059 | spec->auto_mic = 0; |
| 1060 | return false; |
| 1061 | } |
| 1062 | |
| 1063 | imux = spec->input_mux; |
| 1064 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1065 | spec->imux_pins, imux->num_items); |
| 1066 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1067 | spec->imux_pins, imux->num_items); |
| 1068 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1069 | spec->imux_pins, imux->num_items); |
| 1070 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1071 | spec->auto_mic = 0; |
| 1072 | return false; /* no corresponding imux */ |
| 1073 | } |
| 1074 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1075 | snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, |
| 1076 | ALC_MIC_EVENT, alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1077 | if (spec->dock_mic_pin) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1078 | snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, |
| 1079 | ALC_MIC_EVENT, |
| 1080 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1081 | |
| 1082 | spec->auto_mic_valid_imux = 1; |
| 1083 | spec->auto_mic = 1; |
| 1084 | return true; |
| 1085 | } |
| 1086 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1087 | /* |
| 1088 | * Check the availability of auto-mic switch; |
| 1089 | * Set up if really supported |
| 1090 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1091 | static int alc_init_auto_mic(struct hda_codec *codec) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1092 | { |
| 1093 | struct alc_spec *spec = codec->spec; |
| 1094 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1095 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1096 | int i; |
| 1097 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1098 | if (spec->shared_mic_hp) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1099 | return 0; /* no auto-mic for the shared I/O */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1100 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1101 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1102 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1103 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1104 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1105 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1106 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1107 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1108 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1109 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1110 | if (fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1111 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1112 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1113 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1114 | fixed = nid; |
| 1115 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1116 | case INPUT_PIN_ATTR_UNUSED: |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1117 | return 0; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1118 | case INPUT_PIN_ATTR_DOCK: |
| 1119 | if (dock) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1120 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1121 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1122 | return 0; /* invalid type */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1123 | dock = nid; |
| 1124 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1125 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1126 | if (ext) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1127 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1128 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1129 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1130 | ext = nid; |
| 1131 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1132 | } |
| 1133 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1134 | if (!ext && dock) { |
| 1135 | ext = dock; |
| 1136 | dock = 0; |
| 1137 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1138 | if (!ext || !fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1139 | return 0; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1140 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1141 | return 0; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1142 | if (dock && !is_jack_detectable(codec, dock)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1143 | return 0; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1144 | |
| 1145 | /* check imux indices */ |
| 1146 | spec->ext_mic_pin = ext; |
| 1147 | spec->int_mic_pin = fixed; |
| 1148 | spec->dock_mic_pin = dock; |
| 1149 | |
| 1150 | spec->auto_mic = 1; |
| 1151 | if (!alc_auto_mic_check_imux(codec)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1152 | return 0; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1153 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1154 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1155 | ext, fixed, dock); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1156 | |
| 1157 | return 0; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1158 | } |
| 1159 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1160 | /* check the availabilities of auto-mute and auto-mic switches */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1161 | static int alc_auto_check_switches(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1162 | { |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1163 | int err; |
| 1164 | |
| 1165 | err = alc_init_automute(codec); |
| 1166 | if (err < 0) |
| 1167 | return err; |
| 1168 | err = alc_init_auto_mic(codec); |
| 1169 | if (err < 0) |
| 1170 | return err; |
| 1171 | return 0; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | /* |
| 1175 | * Realtek SSID verification |
| 1176 | */ |
| 1177 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1178 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1179 | * the driver to ignore any present sku defines. |
| 1180 | */ |
| 1181 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1182 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1183 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1184 | const struct hda_fixup *fix, int action) |
| 1185 | { |
| 1186 | struct alc_spec *spec = codec->spec; |
| 1187 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1188 | spec->cdefine.fixup = 1; |
| 1189 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1190 | } |
| 1191 | } |
| 1192 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1193 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1194 | { |
| 1195 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1196 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1197 | struct alc_spec *spec = codec->spec; |
| 1198 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1199 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1200 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1201 | if (spec->cdefine.fixup) { |
| 1202 | ass = spec->cdefine.sku_cfg; |
| 1203 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1204 | return -1; |
| 1205 | goto do_sku; |
| 1206 | } |
| 1207 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1208 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1209 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1210 | goto do_sku; |
| 1211 | |
| 1212 | nid = 0x1d; |
| 1213 | if (codec->vendor_id == 0x10ec0260) |
| 1214 | nid = 0x17; |
| 1215 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1216 | |
| 1217 | if (!(ass & 1)) { |
| 1218 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1219 | codec->chip_name, ass); |
| 1220 | return -1; |
| 1221 | } |
| 1222 | |
| 1223 | /* check sum */ |
| 1224 | tmp = 0; |
| 1225 | for (i = 1; i < 16; i++) { |
| 1226 | if ((ass >> i) & 1) |
| 1227 | tmp++; |
| 1228 | } |
| 1229 | if (((ass >> 16) & 0xf) != tmp) |
| 1230 | return -1; |
| 1231 | |
| 1232 | spec->cdefine.port_connectivity = ass >> 30; |
| 1233 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1234 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1235 | spec->cdefine.customization = ass >> 8; |
| 1236 | do_sku: |
| 1237 | spec->cdefine.sku_cfg = ass; |
| 1238 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1239 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1240 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1241 | spec->cdefine.override = ass & 0x1; |
| 1242 | |
| 1243 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1244 | nid, spec->cdefine.sku_cfg); |
| 1245 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1246 | spec->cdefine.port_connectivity); |
| 1247 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1248 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1249 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1250 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1251 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1252 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1253 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1254 | |
| 1255 | return 0; |
| 1256 | } |
| 1257 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1258 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1259 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1260 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1261 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1262 | } |
| 1263 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1264 | /* check subsystem ID and set up device-specific initialization; |
| 1265 | * return 1 if initialized, 0 if invalid SSID |
| 1266 | */ |
| 1267 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1268 | * 31 ~ 16 : Manufacture ID |
| 1269 | * 15 ~ 8 : SKU ID |
| 1270 | * 7 ~ 0 : Assembly ID |
| 1271 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1272 | */ |
| 1273 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1274 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1275 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1276 | { |
| 1277 | unsigned int ass, tmp, i; |
| 1278 | unsigned nid; |
| 1279 | struct alc_spec *spec = codec->spec; |
| 1280 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1281 | if (spec->cdefine.fixup) { |
| 1282 | ass = spec->cdefine.sku_cfg; |
| 1283 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1284 | return 0; |
| 1285 | goto do_sku; |
| 1286 | } |
| 1287 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1288 | ass = codec->subsystem_id & 0xffff; |
| 1289 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1290 | goto do_sku; |
| 1291 | |
| 1292 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1293 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1294 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1295 | * 29~21 : reserve |
| 1296 | * 20 : PCBEEP input |
| 1297 | * 19~16 : Check sum (15:1) |
| 1298 | * 15~1 : Custom |
| 1299 | * 0 : override |
| 1300 | */ |
| 1301 | nid = 0x1d; |
| 1302 | if (codec->vendor_id == 0x10ec0260) |
| 1303 | nid = 0x17; |
| 1304 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1305 | snd_printd("realtek: No valid SSID, " |
| 1306 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1307 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1308 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1309 | return 0; |
| 1310 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1311 | return 0; |
| 1312 | |
| 1313 | /* check sum */ |
| 1314 | tmp = 0; |
| 1315 | for (i = 1; i < 16; i++) { |
| 1316 | if ((ass >> i) & 1) |
| 1317 | tmp++; |
| 1318 | } |
| 1319 | if (((ass >> 16) & 0xf) != tmp) |
| 1320 | return 0; |
| 1321 | do_sku: |
| 1322 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1323 | ass & 0xffff, codec->vendor_id); |
| 1324 | /* |
| 1325 | * 0 : override |
| 1326 | * 1 : Swap Jack |
| 1327 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1328 | * 3~5 : External Amplifier control |
| 1329 | * 7~6 : Reserved |
| 1330 | */ |
| 1331 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1332 | switch (tmp) { |
| 1333 | case 1: |
| 1334 | spec->init_amp = ALC_INIT_GPIO1; |
| 1335 | break; |
| 1336 | case 3: |
| 1337 | spec->init_amp = ALC_INIT_GPIO2; |
| 1338 | break; |
| 1339 | case 7: |
| 1340 | spec->init_amp = ALC_INIT_GPIO3; |
| 1341 | break; |
| 1342 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1343 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1344 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1345 | break; |
| 1346 | } |
| 1347 | |
| 1348 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1349 | * when the external headphone out jack is plugged" |
| 1350 | */ |
| 1351 | if (!(ass & 0x8000)) |
| 1352 | return 1; |
| 1353 | /* |
| 1354 | * 10~8 : Jack location |
| 1355 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1356 | * 14~13: Resvered |
| 1357 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1358 | * when the external headphone out jack is plugged" |
| 1359 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1360 | if (!spec->autocfg.hp_pins[0] && |
| 1361 | !(spec->autocfg.line_out_pins[0] && |
| 1362 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1363 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1364 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1365 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1366 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1367 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1368 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1369 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1370 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1371 | else if (tmp == 3) |
| 1372 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1373 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1374 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1375 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1376 | spec->autocfg.line_outs)) |
| 1377 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1378 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1379 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1380 | return 1; |
| 1381 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1382 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1383 | /* Check the validity of ALC subsystem-id |
| 1384 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1385 | 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] | 1386 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1387 | 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] | 1388 | struct alc_spec *spec = codec->spec; |
| 1389 | snd_printd("realtek: " |
| 1390 | "Enable default setup for auto mode as fallback\n"); |
| 1391 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1392 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1393 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1394 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1395 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1396 | * COEF access helper functions |
| 1397 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1398 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1399 | unsigned int coef_idx) |
| 1400 | { |
| 1401 | unsigned int val; |
| 1402 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1403 | coef_idx); |
| 1404 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1405 | AC_VERB_GET_PROC_COEF, 0); |
| 1406 | return val; |
| 1407 | } |
| 1408 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1409 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1410 | unsigned int coef_val) |
| 1411 | { |
| 1412 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1413 | coef_idx); |
| 1414 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1415 | coef_val); |
| 1416 | } |
| 1417 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1418 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1419 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1420 | { |
| 1421 | struct alc_spec *spec = codec->spec; |
| 1422 | if (!spec->coef0) |
| 1423 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1424 | return spec->coef0; |
| 1425 | } |
| 1426 | |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1427 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 1428 | hda_nid_t pin, int pin_type, |
| 1429 | hda_nid_t dac); |
| 1430 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 1431 | bool is_digital); |
| 1432 | static bool add_new_out_path(struct hda_codec *codec, hda_nid_t pin, |
| 1433 | hda_nid_t dac); |
| 1434 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1435 | /* |
| 1436 | * Digital I/O handling |
| 1437 | */ |
| 1438 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1439 | /* set right pin controls for digital I/O */ |
| 1440 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1441 | { |
| 1442 | struct alc_spec *spec = codec->spec; |
| 1443 | int i; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1444 | hda_nid_t pin; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1445 | |
| 1446 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1447 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1448 | if (!pin) |
| 1449 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1450 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1451 | } |
| 1452 | pin = spec->autocfg.dig_in_pin; |
| 1453 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1454 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1458 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1459 | { |
| 1460 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1461 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1462 | hda_nid_t dig_nid; |
| 1463 | |
| 1464 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1465 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1466 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1467 | hda_nid_t pin = spec->autocfg.dig_out_pins[i]; |
| 1468 | dig_nid = alc_auto_look_for_dac(codec, pin, true); |
| 1469 | if (!dig_nid) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1470 | continue; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1471 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1472 | spec->multiout.dig_out_nid = dig_nid; |
| 1473 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1474 | } else { |
| 1475 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1476 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1477 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1478 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1479 | } |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1480 | add_new_out_path(codec, pin, dig_nid); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1481 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1482 | } |
| 1483 | |
| 1484 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1485 | dig_nid = codec->start_nid; |
| 1486 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1487 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1488 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1489 | continue; |
| 1490 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1491 | continue; |
| 1492 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1493 | continue; |
| 1494 | err = get_connection_index(codec, dig_nid, |
| 1495 | spec->autocfg.dig_in_pin); |
| 1496 | if (err >= 0) { |
| 1497 | spec->dig_in_nid = dig_nid; |
| 1498 | break; |
| 1499 | } |
| 1500 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1501 | } |
| 1502 | } |
| 1503 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1504 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1505 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1506 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1507 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1508 | struct snd_ctl_elem_info *uinfo) |
| 1509 | { |
| 1510 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1511 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1512 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1513 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1514 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1515 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1516 | if (spec->vol_in_capsrc) |
| 1517 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1518 | else |
| 1519 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1520 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1521 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1522 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1523 | return err; |
| 1524 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1526 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1527 | unsigned int size, unsigned int __user *tlv) |
| 1528 | { |
| 1529 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1530 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1531 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1532 | int err; |
| 1533 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1534 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1535 | if (spec->vol_in_capsrc) |
| 1536 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1537 | else |
| 1538 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1539 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1540 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1541 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1542 | return err; |
| 1543 | } |
| 1544 | |
| 1545 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1546 | struct snd_ctl_elem_value *ucontrol); |
| 1547 | |
| 1548 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1549 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1550 | getput_call_t func, bool is_put) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1551 | { |
| 1552 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1553 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1554 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1555 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1556 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1557 | if (is_put && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1558 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1559 | kcontrol->private_value = |
| 1560 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1561 | 3, 0, HDA_INPUT); |
| 1562 | err = func(kcontrol, ucontrol); |
| 1563 | if (err < 0) |
| 1564 | goto error; |
| 1565 | } |
| 1566 | } else { |
| 1567 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1568 | if (spec->vol_in_capsrc) |
| 1569 | kcontrol->private_value = |
| 1570 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1571 | 3, 0, HDA_OUTPUT); |
| 1572 | else |
| 1573 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1574 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1575 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1576 | err = func(kcontrol, ucontrol); |
| 1577 | } |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1578 | if (err >= 0 && is_put) |
| 1579 | alc_inv_dmic_sync(codec, false); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1580 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1581 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1582 | return err; |
| 1583 | } |
| 1584 | |
| 1585 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1586 | struct snd_ctl_elem_value *ucontrol) |
| 1587 | { |
| 1588 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1589 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1590 | } |
| 1591 | |
| 1592 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1593 | struct snd_ctl_elem_value *ucontrol) |
| 1594 | { |
| 1595 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1596 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1597 | } |
| 1598 | |
| 1599 | /* capture mixer elements */ |
| 1600 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1601 | |
| 1602 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1603 | struct snd_ctl_elem_value *ucontrol) |
| 1604 | { |
| 1605 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1606 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1610 | struct snd_ctl_elem_value *ucontrol) |
| 1611 | { |
| 1612 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1613 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1614 | } |
| 1615 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1616 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1617 | { \ |
| 1618 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1619 | .name = "Capture Switch", \ |
| 1620 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1621 | .count = num, \ |
| 1622 | .info = alc_cap_sw_info, \ |
| 1623 | .get = alc_cap_sw_get, \ |
| 1624 | .put = alc_cap_sw_put, \ |
| 1625 | }, \ |
| 1626 | { \ |
| 1627 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1628 | .name = "Capture Volume", \ |
| 1629 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1630 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1631 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1632 | .count = num, \ |
| 1633 | .info = alc_cap_vol_info, \ |
| 1634 | .get = alc_cap_vol_get, \ |
| 1635 | .put = alc_cap_vol_put, \ |
| 1636 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1640 | { \ |
| 1641 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1642 | /* .name = "Capture Source", */ \ |
| 1643 | .name = "Input Source", \ |
| 1644 | .count = num, \ |
| 1645 | .info = alc_mux_enum_info, \ |
| 1646 | .get = alc_mux_enum_get, \ |
| 1647 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1648 | } |
| 1649 | |
| 1650 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1651 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1652 | _DEFINE_CAPMIX(num), \ |
| 1653 | _DEFINE_CAPSRC(num), \ |
| 1654 | { } /* end */ \ |
| 1655 | } |
| 1656 | |
| 1657 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1658 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1659 | _DEFINE_CAPMIX(num), \ |
| 1660 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1661 | } |
| 1662 | |
| 1663 | /* up to three ADCs */ |
| 1664 | DEFINE_CAPMIX(1); |
| 1665 | DEFINE_CAPMIX(2); |
| 1666 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1667 | DEFINE_CAPMIX_NOSRC(1); |
| 1668 | DEFINE_CAPMIX_NOSRC(2); |
| 1669 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1670 | |
| 1671 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1672 | * Inverted digital-mic handling |
| 1673 | * |
| 1674 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1675 | * gives the additional mute only to the right channel of the digital mic |
| 1676 | * capture stream. This is a workaround for avoiding the almost silence |
| 1677 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1678 | * digital mic unit. |
| 1679 | * |
| 1680 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1681 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1682 | * without caching so that the cache can still keep the original value. |
| 1683 | * The cached value is then restored when the flag is set off or any other |
| 1684 | * than d-mic is used as the current input source. |
| 1685 | */ |
| 1686 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1687 | { |
| 1688 | struct alc_spec *spec = codec->spec; |
| 1689 | int i; |
| 1690 | |
| 1691 | if (!spec->inv_dmic_fixup) |
| 1692 | return; |
| 1693 | if (!spec->inv_dmic_muted && !force) |
| 1694 | return; |
| 1695 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1696 | int src = spec->dyn_adc_switch ? 0 : i; |
| 1697 | bool dmic_fixup = false; |
| 1698 | hda_nid_t nid; |
| 1699 | int parm, dir, v; |
| 1700 | |
| 1701 | if (spec->inv_dmic_muted && |
| 1702 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1703 | dmic_fixup = true; |
| 1704 | if (!dmic_fixup && !force) |
| 1705 | continue; |
| 1706 | if (spec->vol_in_capsrc) { |
| 1707 | nid = spec->capsrc_nids[i]; |
| 1708 | parm = AC_AMP_SET_RIGHT | AC_AMP_SET_OUTPUT; |
| 1709 | dir = HDA_OUTPUT; |
| 1710 | } else { |
| 1711 | nid = spec->adc_nids[i]; |
| 1712 | parm = AC_AMP_SET_RIGHT | AC_AMP_SET_INPUT; |
| 1713 | dir = HDA_INPUT; |
| 1714 | } |
| 1715 | /* we care only right channel */ |
| 1716 | v = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1717 | if (v & 0x80) /* if already muted, we don't need to touch */ |
| 1718 | continue; |
| 1719 | if (dmic_fixup) /* add mute for d-mic */ |
| 1720 | v |= 0x80; |
| 1721 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1722 | parm | v); |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1727 | struct snd_ctl_elem_value *ucontrol) |
| 1728 | { |
| 1729 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1730 | struct alc_spec *spec = codec->spec; |
| 1731 | |
| 1732 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
| 1736 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1737 | struct snd_ctl_elem_value *ucontrol) |
| 1738 | { |
| 1739 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1740 | struct alc_spec *spec = codec->spec; |
| 1741 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1742 | |
| 1743 | if (val == spec->inv_dmic_muted) |
| 1744 | return 0; |
| 1745 | spec->inv_dmic_muted = val; |
| 1746 | alc_inv_dmic_sync(codec, true); |
| 1747 | return 0; |
| 1748 | } |
| 1749 | |
| 1750 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1751 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1752 | .info = snd_ctl_boolean_mono_info, |
| 1753 | .get = alc_inv_dmic_sw_get, |
| 1754 | .put = alc_inv_dmic_sw_put, |
| 1755 | }; |
| 1756 | |
| 1757 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1758 | { |
| 1759 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 1760 | |
| 1761 | if (!alc_kcontrol_new(spec, "Inverted Internal Mic Capture Switch", |
| 1762 | &alc_inv_dmic_sw)) |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1763 | return -ENOMEM; |
| 1764 | spec->inv_dmic_fixup = 1; |
| 1765 | spec->inv_dmic_muted = 0; |
| 1766 | spec->inv_dmic_pin = nid; |
| 1767 | return 0; |
| 1768 | } |
| 1769 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1770 | /* typically the digital mic is put at node 0x12 */ |
| 1771 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1772 | const struct alc_fixup *fix, int action) |
| 1773 | { |
| 1774 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1775 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1776 | } |
| 1777 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1778 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1779 | * virtual master controls |
| 1780 | */ |
| 1781 | |
| 1782 | /* |
| 1783 | * slave controls for virtual master |
| 1784 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1785 | static const char * const alc_slave_pfxs[] = { |
| 1786 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1787 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1788 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1789 | NULL, |
| 1790 | }; |
| 1791 | |
| 1792 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1793 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1795 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1796 | #define NID_MAPPING (-1) |
| 1797 | |
| 1798 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1799 | #define SUBDEV_HP_ (1 << 6) |
| 1800 | #define SUBDEV_LINE_ (2 << 6) |
| 1801 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1802 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1803 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1804 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1805 | static void alc_free_kctls(struct hda_codec *codec); |
| 1806 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1807 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1808 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1809 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1810 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1811 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1812 | { } /* end */ |
| 1813 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1814 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1815 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1816 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | { |
| 1818 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1819 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1820 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1821 | int i, j, err; |
| 1822 | unsigned int u; |
| 1823 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | |
| 1825 | for (i = 0; i < spec->num_mixers; i++) { |
| 1826 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1827 | if (err < 0) |
| 1828 | return err; |
| 1829 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1830 | if (spec->cap_mixer) { |
| 1831 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1832 | if (err < 0) |
| 1833 | return err; |
| 1834 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1835 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1836 | err = snd_hda_create_dig_out_ctls(codec, |
| 1837 | spec->multiout.dig_out_nid, |
| 1838 | spec->multiout.dig_out_nid, |
| 1839 | spec->pcm_rec[1].pcm_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | if (err < 0) |
| 1841 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1842 | if (!spec->no_analog) { |
| 1843 | err = snd_hda_create_spdif_share_sw(codec, |
| 1844 | &spec->multiout); |
| 1845 | if (err < 0) |
| 1846 | return err; |
| 1847 | spec->multiout.share_spdif = 1; |
| 1848 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1849 | } |
| 1850 | if (spec->dig_in_nid) { |
| 1851 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1852 | if (err < 0) |
| 1853 | return err; |
| 1854 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1855 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1856 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1857 | /* create beep controls if needed */ |
| 1858 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1859 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1860 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1861 | struct snd_kcontrol *kctl; |
| 1862 | kctl = snd_ctl_new1(knew, codec); |
| 1863 | if (!kctl) |
| 1864 | return -ENOMEM; |
| 1865 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1866 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1867 | if (err < 0) |
| 1868 | return err; |
| 1869 | } |
| 1870 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1871 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1872 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1873 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1874 | if (!spec->no_analog && |
| 1875 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1876 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1877 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1878 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1879 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1880 | vmaster_tlv, alc_slave_pfxs, |
| 1881 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1882 | if (err < 0) |
| 1883 | return err; |
| 1884 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1885 | if (!spec->no_analog && |
| 1886 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1887 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1888 | NULL, alc_slave_pfxs, |
| 1889 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1890 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1891 | if (err < 0) |
| 1892 | return err; |
| 1893 | } |
| 1894 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1895 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1896 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1897 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1898 | if (!kctl) |
| 1899 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1900 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1901 | err = snd_hda_add_nid(codec, kctl, i, |
| 1902 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1903 | if (err < 0) |
| 1904 | return err; |
| 1905 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1906 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1907 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1908 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1909 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1910 | if (kname && strcmp(knew->name, kname) == 0) |
| 1911 | continue; |
| 1912 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1913 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1914 | err = snd_hda_add_nid(codec, kctl, i, |
| 1915 | spec->adc_nids[i]); |
| 1916 | if (err < 0) |
| 1917 | return err; |
| 1918 | } |
| 1919 | } |
| 1920 | } |
| 1921 | |
| 1922 | /* other nid->control mapping */ |
| 1923 | for (i = 0; i < spec->num_mixers; i++) { |
| 1924 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1925 | if (knew->iface != NID_MAPPING) |
| 1926 | continue; |
| 1927 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1928 | if (kctl == NULL) |
| 1929 | continue; |
| 1930 | u = knew->subdevice; |
| 1931 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1932 | nid = u & 0x3f; |
| 1933 | if (nid == 0) |
| 1934 | continue; |
| 1935 | switch (u & 0xc0) { |
| 1936 | case SUBDEV_SPEAKER_: |
| 1937 | nid = spec->autocfg.speaker_pins[nid]; |
| 1938 | break; |
| 1939 | case SUBDEV_LINE_: |
| 1940 | nid = spec->autocfg.line_out_pins[nid]; |
| 1941 | break; |
| 1942 | case SUBDEV_HP_: |
| 1943 | nid = spec->autocfg.hp_pins[nid]; |
| 1944 | break; |
| 1945 | default: |
| 1946 | continue; |
| 1947 | } |
| 1948 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1949 | if (err < 0) |
| 1950 | return err; |
| 1951 | } |
| 1952 | u = knew->private_value; |
| 1953 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1954 | nid = u & 0xff; |
| 1955 | if (nid == 0) |
| 1956 | continue; |
| 1957 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1958 | if (err < 0) |
| 1959 | return err; |
| 1960 | } |
| 1961 | } |
| 1962 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1963 | |
| 1964 | alc_free_kctls(codec); /* no longer needed */ |
| 1965 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1966 | return 0; |
| 1967 | } |
| 1968 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1969 | static int alc_build_jacks(struct hda_codec *codec) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1970 | { |
| 1971 | struct alc_spec *spec = codec->spec; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1972 | |
| 1973 | if (spec->shared_mic_hp) { |
| 1974 | int err; |
| 1975 | int nid = spec->autocfg.inputs[1].pin; |
| 1976 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1977 | if (err < 0) |
| 1978 | return err; |
| 1979 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1980 | if (err < 0) |
| 1981 | return err; |
| 1982 | } |
| 1983 | |
| 1984 | return snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1985 | } |
| 1986 | |
| 1987 | static int alc_build_controls(struct hda_codec *codec) |
| 1988 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1989 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1990 | if (err < 0) |
| 1991 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1992 | |
| 1993 | err = alc_build_jacks(codec); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1994 | if (err < 0) |
| 1995 | return err; |
| 1996 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1997 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | } |
| 1999 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2000 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2002 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2003 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2004 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2005 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2006 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | static int alc_init(struct hda_codec *codec) |
| 2009 | { |
| 2010 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2011 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 2012 | if (spec->init_hook) |
| 2013 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 2014 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2015 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2016 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2017 | |
Takashi Iwai | 2e8b2b2 | 2012-06-13 16:47:32 +0200 | [diff] [blame] | 2018 | snd_hda_gen_apply_verbs(codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2019 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2020 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2021 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2022 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2023 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2024 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | return 0; |
| 2026 | } |
| 2027 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2028 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2029 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2030 | { |
| 2031 | struct alc_spec *spec = codec->spec; |
| 2032 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2033 | } |
| 2034 | #endif |
| 2035 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2036 | /* |
| 2037 | * Analog playback callbacks |
| 2038 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2039 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2041 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | { |
| 2043 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2044 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2045 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2046 | } |
| 2047 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2048 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | struct hda_codec *codec, |
| 2050 | unsigned int stream_tag, |
| 2051 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2052 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | { |
| 2054 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2055 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2056 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | } |
| 2058 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2059 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2060 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2061 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | { |
| 2063 | struct alc_spec *spec = codec->spec; |
| 2064 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2065 | } |
| 2066 | |
| 2067 | /* |
| 2068 | * Digital out |
| 2069 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2070 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2072 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2073 | { |
| 2074 | struct alc_spec *spec = codec->spec; |
| 2075 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2076 | } |
| 2077 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2078 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2079 | struct hda_codec *codec, |
| 2080 | unsigned int stream_tag, |
| 2081 | unsigned int format, |
| 2082 | struct snd_pcm_substream *substream) |
| 2083 | { |
| 2084 | struct alc_spec *spec = codec->spec; |
| 2085 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2086 | stream_tag, format, substream); |
| 2087 | } |
| 2088 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2089 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2090 | struct hda_codec *codec, |
| 2091 | struct snd_pcm_substream *substream) |
| 2092 | { |
| 2093 | struct alc_spec *spec = codec->spec; |
| 2094 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2095 | } |
| 2096 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2097 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2099 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | { |
| 2101 | struct alc_spec *spec = codec->spec; |
| 2102 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2103 | } |
| 2104 | |
| 2105 | /* |
| 2106 | * Analog capture |
| 2107 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2108 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | struct hda_codec *codec, |
| 2110 | unsigned int stream_tag, |
| 2111 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2112 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | { |
| 2114 | struct alc_spec *spec = codec->spec; |
| 2115 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2116 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2117 | stream_tag, 0, format); |
| 2118 | return 0; |
| 2119 | } |
| 2120 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2121 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2123 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | { |
| 2125 | struct alc_spec *spec = codec->spec; |
| 2126 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2127 | snd_hda_codec_cleanup_stream(codec, |
| 2128 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | return 0; |
| 2130 | } |
| 2131 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2132 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2133 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2134 | struct hda_codec *codec, |
| 2135 | unsigned int stream_tag, |
| 2136 | unsigned int format, |
| 2137 | struct snd_pcm_substream *substream) |
| 2138 | { |
| 2139 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2140 | spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2141 | spec->cur_adc_stream_tag = stream_tag; |
| 2142 | spec->cur_adc_format = format; |
| 2143 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2144 | return 0; |
| 2145 | } |
| 2146 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2147 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2148 | struct hda_codec *codec, |
| 2149 | struct snd_pcm_substream *substream) |
| 2150 | { |
| 2151 | struct alc_spec *spec = codec->spec; |
| 2152 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2153 | spec->cur_adc = 0; |
| 2154 | return 0; |
| 2155 | } |
| 2156 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2157 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2158 | .substreams = 1, |
| 2159 | .channels_min = 2, |
| 2160 | .channels_max = 2, |
| 2161 | .nid = 0, /* fill later */ |
| 2162 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2163 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2164 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2165 | }, |
| 2166 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | |
| 2168 | /* |
| 2169 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2170 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | .substreams = 1, |
| 2172 | .channels_min = 2, |
| 2173 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2174 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2176 | .open = alc_playback_pcm_open, |
| 2177 | .prepare = alc_playback_pcm_prepare, |
| 2178 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | }, |
| 2180 | }; |
| 2181 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2182 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2183 | .substreams = 1, |
| 2184 | .channels_min = 2, |
| 2185 | .channels_max = 2, |
| 2186 | /* NID is set in alc_build_pcms */ |
| 2187 | }; |
| 2188 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2189 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2190 | .substreams = 1, |
| 2191 | .channels_min = 2, |
| 2192 | .channels_max = 2, |
| 2193 | /* NID is set in alc_build_pcms */ |
| 2194 | }; |
| 2195 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2196 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2197 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | .channels_min = 2, |
| 2199 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2200 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2202 | .prepare = alc_alt_capture_pcm_prepare, |
| 2203 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2204 | }, |
| 2205 | }; |
| 2206 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2207 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | .substreams = 1, |
| 2209 | .channels_min = 2, |
| 2210 | .channels_max = 2, |
| 2211 | /* NID is set in alc_build_pcms */ |
| 2212 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2213 | .open = alc_dig_playback_pcm_open, |
| 2214 | .close = alc_dig_playback_pcm_close, |
| 2215 | .prepare = alc_dig_playback_pcm_prepare, |
| 2216 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | }, |
| 2218 | }; |
| 2219 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2220 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2221 | .substreams = 1, |
| 2222 | .channels_min = 2, |
| 2223 | .channels_max = 2, |
| 2224 | /* NID is set in alc_build_pcms */ |
| 2225 | }; |
| 2226 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2227 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2228 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2229 | .substreams = 0, |
| 2230 | .channels_min = 0, |
| 2231 | .channels_max = 0, |
| 2232 | }; |
| 2233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | static int alc_build_pcms(struct hda_codec *codec) |
| 2235 | { |
| 2236 | struct alc_spec *spec = codec->spec; |
| 2237 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2238 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2239 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | int i; |
| 2241 | |
| 2242 | codec->num_pcms = 1; |
| 2243 | codec->pcm_info = info; |
| 2244 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2245 | if (spec->no_analog) |
| 2246 | goto skip_analog; |
| 2247 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2248 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2249 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2251 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2252 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2253 | p = spec->stream_analog_playback; |
| 2254 | if (!p) |
| 2255 | p = &alc_pcm_analog_playback; |
| 2256 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2257 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 2258 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 2259 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 2260 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 2261 | spec->autocfg.line_outs == 2) |
| 2262 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 2263 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2264 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2265 | if (spec->adc_nids) { |
| 2266 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2267 | if (!p) { |
| 2268 | if (spec->dyn_adc_switch) |
| 2269 | p = &dyn_adc_pcm_analog_capture; |
| 2270 | else |
| 2271 | p = &alc_pcm_analog_capture; |
| 2272 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2273 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2274 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2275 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2277 | if (spec->channel_mode) { |
| 2278 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2279 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2280 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2281 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2282 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | } |
| 2284 | } |
| 2285 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2286 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2287 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2289 | snprintf(spec->stream_name_digital, |
| 2290 | sizeof(spec->stream_name_digital), |
| 2291 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2292 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2293 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2294 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2295 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2296 | if (spec->dig_out_type) |
| 2297 | info->pcm_type = spec->dig_out_type; |
| 2298 | else |
| 2299 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2300 | if (spec->multiout.dig_out_nid) { |
| 2301 | p = spec->stream_digital_playback; |
| 2302 | if (!p) |
| 2303 | p = &alc_pcm_digital_playback; |
| 2304 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2305 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2306 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2307 | if (spec->dig_in_nid) { |
| 2308 | p = spec->stream_digital_capture; |
| 2309 | if (!p) |
| 2310 | p = &alc_pcm_digital_capture; |
| 2311 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2313 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2314 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2315 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | } |
| 2317 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2318 | if (spec->no_analog) |
| 2319 | return 0; |
| 2320 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2321 | /* If the use of more than one ADC is requested for the current |
| 2322 | * model, configure a second analog capture-only PCM. |
| 2323 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2324 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2325 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2326 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2327 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2328 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2329 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2330 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2331 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2332 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2333 | p = spec->stream_analog_alt_playback; |
| 2334 | if (!p) |
| 2335 | p = &alc_pcm_analog_alt_playback; |
| 2336 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2337 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2338 | spec->alt_dac_nid; |
| 2339 | } else { |
| 2340 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2341 | alc_pcm_null_stream; |
| 2342 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2343 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2344 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2345 | p = spec->stream_analog_alt_capture; |
| 2346 | if (!p) |
| 2347 | p = &alc_pcm_analog_alt_capture; |
| 2348 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2349 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2350 | spec->adc_nids[1]; |
| 2351 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2352 | spec->num_adc_nids - 1; |
| 2353 | } else { |
| 2354 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2355 | alc_pcm_null_stream; |
| 2356 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2357 | } |
| 2358 | } |
| 2359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2360 | return 0; |
| 2361 | } |
| 2362 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2363 | static inline void alc_shutup(struct hda_codec *codec) |
| 2364 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2365 | struct alc_spec *spec = codec->spec; |
| 2366 | |
| 2367 | if (spec && spec->shutup) |
| 2368 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2369 | snd_hda_shutup_pins(codec); |
| 2370 | } |
| 2371 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2372 | static void alc_free_kctls(struct hda_codec *codec) |
| 2373 | { |
| 2374 | struct alc_spec *spec = codec->spec; |
| 2375 | |
| 2376 | if (spec->kctls.list) { |
| 2377 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2378 | int i; |
| 2379 | for (i = 0; i < spec->kctls.used; i++) |
| 2380 | kfree(kctl[i].name); |
| 2381 | } |
| 2382 | snd_array_free(&spec->kctls); |
| 2383 | } |
| 2384 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2385 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2386 | { |
| 2387 | struct alc_spec *spec = codec->spec; |
| 2388 | if (spec->bind_ctls.list) { |
| 2389 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2390 | int i; |
| 2391 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2392 | kfree(ctl[i]); |
| 2393 | } |
| 2394 | snd_array_free(&spec->bind_ctls); |
| 2395 | } |
| 2396 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2397 | static void alc_free(struct hda_codec *codec) |
| 2398 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2399 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2400 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2401 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2402 | return; |
| 2403 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2404 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2405 | alc_free_bind_ctls(codec); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2406 | snd_array_free(&spec->paths); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 2407 | snd_hda_gen_free(&spec->gen); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2408 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2409 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2410 | } |
| 2411 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2412 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2413 | static void alc_power_eapd(struct hda_codec *codec) |
| 2414 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2415 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2416 | } |
| 2417 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2418 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2419 | { |
| 2420 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2421 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2422 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2423 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2424 | return 0; |
| 2425 | } |
| 2426 | #endif |
| 2427 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2428 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2429 | static int alc_resume(struct hda_codec *codec) |
| 2430 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2431 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2432 | codec->patch_ops.init(codec); |
| 2433 | snd_hda_codec_resume_amp(codec); |
| 2434 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2435 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2436 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2437 | return 0; |
| 2438 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2439 | #endif |
| 2440 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | /* |
| 2442 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2443 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2444 | .build_controls = alc_build_controls, |
| 2445 | .build_pcms = alc_build_pcms, |
| 2446 | .init = alc_init, |
| 2447 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2448 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2449 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2450 | .resume = alc_resume, |
| 2451 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2452 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2453 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2454 | .check_power_status = alc_check_power_status, |
| 2455 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2456 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | }; |
| 2458 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2459 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2460 | /* replace the codec chip_name with the given string */ |
| 2461 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2462 | { |
| 2463 | kfree(codec->chip_name); |
| 2464 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2465 | if (!codec->chip_name) { |
| 2466 | alc_free(codec); |
| 2467 | return -ENOMEM; |
| 2468 | } |
| 2469 | return 0; |
| 2470 | } |
| 2471 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2472 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2473 | * Rename codecs appropriately from COEF value |
| 2474 | */ |
| 2475 | struct alc_codec_rename_table { |
| 2476 | unsigned int vendor_id; |
| 2477 | unsigned short coef_mask; |
| 2478 | unsigned short coef_bits; |
| 2479 | const char *name; |
| 2480 | }; |
| 2481 | |
| 2482 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2483 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2484 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2485 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2486 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2487 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2488 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2489 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2490 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2491 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2492 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2493 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2494 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2495 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2496 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2497 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2498 | { } /* terminator */ |
| 2499 | }; |
| 2500 | |
| 2501 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2502 | { |
| 2503 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2504 | |
| 2505 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2506 | if (p->vendor_id != codec->vendor_id) |
| 2507 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2508 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2509 | return alc_codec_rename(codec, p->name); |
| 2510 | } |
| 2511 | return 0; |
| 2512 | } |
| 2513 | |
| 2514 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2515 | * Automatic parse of I/O pins from the BIOS configuration |
| 2516 | */ |
| 2517 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2518 | enum { |
| 2519 | ALC_CTL_WIDGET_VOL, |
| 2520 | ALC_CTL_WIDGET_MUTE, |
| 2521 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2522 | ALC_CTL_BIND_VOL, |
| 2523 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2524 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2525 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2526 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2527 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2528 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2529 | HDA_BIND_VOL(NULL, 0), |
| 2530 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2531 | }; |
| 2532 | |
| 2533 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2534 | 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] | 2535 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2536 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2537 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2538 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 2539 | knew = alc_kcontrol_new(spec, name, &alc_control_templates[type]); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2540 | if (!knew) |
| 2541 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2542 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2543 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2544 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2545 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2546 | return 0; |
| 2547 | } |
| 2548 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2549 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2550 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2551 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2552 | { |
| 2553 | char name[32]; |
| 2554 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2555 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2556 | } |
| 2557 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2558 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2559 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2560 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2561 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2562 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2563 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2564 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2565 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2566 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2567 | static const char * const channel_name[4] = { |
| 2568 | "Front", "Surround", "CLFE", "Side" |
| 2569 | }; |
| 2570 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2571 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2572 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2573 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2574 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2575 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2576 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2577 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2578 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2579 | return "Master"; |
| 2580 | |
| 2581 | switch (cfg->line_out_type) { |
| 2582 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2583 | if (cfg->line_outs == 1) |
| 2584 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2585 | if (cfg->line_outs == 2) |
| 2586 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2587 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2588 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2589 | /* for multi-io case, only the primary out */ |
| 2590 | if (ch && spec->multi_ios) |
| 2591 | break; |
| 2592 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2593 | return "Headphone"; |
| 2594 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2595 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2596 | return "PCM"; |
| 2597 | break; |
| 2598 | } |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2599 | if (ch >= ARRAY_SIZE(channel_name)) { |
| 2600 | snd_BUG(); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2601 | return "PCM"; |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2602 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2603 | |
| 2604 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2605 | } |
| 2606 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2607 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2608 | hda_nid_t to_nid, int with_aa_mix, |
| 2609 | struct nid_path *path); |
| 2610 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2611 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2612 | /* add the powersave loopback-list entry */ |
| 2613 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2614 | { |
| 2615 | struct hda_amp_list *list; |
| 2616 | |
| 2617 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2618 | return; |
| 2619 | list = spec->loopback_list + spec->num_loopbacks; |
| 2620 | list->nid = mix; |
| 2621 | list->dir = HDA_INPUT; |
| 2622 | list->idx = idx; |
| 2623 | spec->num_loopbacks++; |
| 2624 | spec->loopback.amplist = spec->loopback_list; |
| 2625 | } |
| 2626 | #else |
| 2627 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2628 | #endif |
| 2629 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2630 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2631 | 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] | 2632 | const char *ctlname, int ctlidx, |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2633 | hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2634 | { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2635 | struct alc_spec *spec = codec->spec; |
| 2636 | struct nid_path *path; |
| 2637 | int err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2638 | |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2639 | if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && |
| 2640 | !nid_has_mute(codec, mix_nid, HDA_INPUT)) |
| 2641 | return 0; /* no need for analog loopback */ |
| 2642 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2643 | path = snd_array_new(&spec->paths); |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2644 | if (!path) |
| 2645 | return -ENOMEM; |
| 2646 | memset(path, 0, sizeof(*path)); |
| 2647 | if (!parse_nid_path(codec, pin, mix_nid, 2, path)) |
| 2648 | return -EINVAL; |
| 2649 | |
| 2650 | idx = path->idx[path->depth - 1]; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2651 | if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { |
| 2652 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2653 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2654 | if (err < 0) |
| 2655 | return err; |
| 2656 | } |
| 2657 | |
| 2658 | if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { |
| 2659 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2660 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2661 | if (err < 0) |
| 2662 | return err; |
| 2663 | } |
| 2664 | |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2665 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2666 | return 0; |
| 2667 | } |
| 2668 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2669 | static int new_capture_source(struct hda_codec *codec, int adc_idx, |
| 2670 | hda_nid_t pin, int idx, const char *label) |
| 2671 | { |
| 2672 | struct alc_spec *spec = codec->spec; |
| 2673 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 2674 | struct nid_path *path; |
| 2675 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2676 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2677 | if (!path) |
| 2678 | return -ENOMEM; |
| 2679 | memset(path, 0, sizeof(*path)); |
| 2680 | if (!parse_nid_path(codec, pin, spec->adc_nids[adc_idx], 2, path)) { |
| 2681 | snd_printd(KERN_ERR "invalid input path 0x%x -> 0x%x\n", |
| 2682 | pin, spec->adc_nids[adc_idx]); |
| 2683 | return -EINVAL; |
| 2684 | } |
| 2685 | |
| 2686 | spec->imux_pins[imux->num_items] = pin; |
| 2687 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2688 | return 0; |
| 2689 | } |
| 2690 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2691 | 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] | 2692 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2693 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2694 | return (pincap & AC_PINCAP_IN) != 0; |
| 2695 | } |
| 2696 | |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2697 | /* check whether the given two widgets can be connected */ |
| 2698 | static bool is_reachable_path(struct hda_codec *codec, |
| 2699 | hda_nid_t from_nid, hda_nid_t to_nid) |
| 2700 | { |
| 2701 | if (!from_nid || !to_nid) |
| 2702 | return false; |
| 2703 | return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; |
| 2704 | } |
| 2705 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2706 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2707 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2708 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2709 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2710 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2711 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2712 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2713 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2714 | int i, nums = 0; |
| 2715 | |
| 2716 | nid = codec->start_nid; |
| 2717 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2718 | hda_nid_t src; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2719 | unsigned int caps = get_wcaps(codec, nid); |
| 2720 | int type = get_wcaps_type(caps); |
| 2721 | |
| 2722 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2723 | continue; |
| 2724 | adc_nids[nums] = nid; |
| 2725 | cap_nids[nums] = nid; |
| 2726 | src = nid; |
| 2727 | for (;;) { |
| 2728 | int n; |
| 2729 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2730 | if (type == AC_WID_PIN) |
| 2731 | break; |
| 2732 | if (type == AC_WID_AUD_SEL) { |
| 2733 | cap_nids[nums] = src; |
| 2734 | break; |
| 2735 | } |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2736 | n = snd_hda_get_num_conns(codec, src); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2737 | if (n > 1) { |
| 2738 | cap_nids[nums] = src; |
| 2739 | break; |
| 2740 | } else if (n != 1) |
| 2741 | break; |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2742 | if (snd_hda_get_connections(codec, src, &src, 1) != 1) |
| 2743 | break; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2744 | } |
| 2745 | if (++nums >= max_nums) |
| 2746 | break; |
| 2747 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2748 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2749 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2750 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2751 | return nums; |
| 2752 | } |
| 2753 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2754 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2755 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2756 | { |
| 2757 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2758 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2759 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2760 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2761 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2762 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2763 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2764 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2765 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2766 | if (num_adcs < 0) |
| 2767 | return 0; |
| 2768 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2769 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2770 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2771 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2772 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2773 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2774 | if (!alc_is_input_pin(codec, pin)) |
| 2775 | continue; |
| 2776 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2777 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2778 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2779 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2780 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2781 | type_idx++; |
| 2782 | else |
| 2783 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2784 | prev_label = label; |
| 2785 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2786 | if (mixer) { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2787 | if (is_reachable_path(codec, pin, mixer)) { |
| 2788 | err = new_analog_input(codec, pin, |
| 2789 | label, type_idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2790 | if (err < 0) |
| 2791 | return err; |
| 2792 | } |
| 2793 | } |
| 2794 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2795 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2796 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2797 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2798 | if (idx >= 0) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2799 | err = new_capture_source(codec, c, pin, idx, label); |
| 2800 | if (err < 0) |
| 2801 | return err; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2802 | break; |
| 2803 | } |
| 2804 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2805 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2806 | |
| 2807 | spec->num_mux_defs = 1; |
| 2808 | spec->input_mux = imux; |
| 2809 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2810 | return 0; |
| 2811 | } |
| 2812 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2813 | /* create a shared input with the headphone out */ |
| 2814 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2815 | { |
| 2816 | struct alc_spec *spec = codec->spec; |
| 2817 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2818 | unsigned int defcfg; |
| 2819 | hda_nid_t nid; |
| 2820 | |
| 2821 | /* only one internal input pin? */ |
| 2822 | if (cfg->num_inputs != 1) |
| 2823 | return 0; |
| 2824 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2825 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2826 | return 0; |
| 2827 | |
| 2828 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2829 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2830 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2831 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2832 | else |
| 2833 | return 0; /* both not available */ |
| 2834 | |
| 2835 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2836 | return 0; /* no input */ |
| 2837 | |
| 2838 | cfg->inputs[1].pin = nid; |
| 2839 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2840 | cfg->num_inputs = 2; |
| 2841 | spec->shared_mic_hp = 1; |
| 2842 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2843 | return 0; |
| 2844 | } |
| 2845 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2846 | static int get_pin_type(int line_out_type) |
| 2847 | { |
| 2848 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2849 | return PIN_HP; |
| 2850 | else |
| 2851 | return PIN_OUT; |
| 2852 | } |
| 2853 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2854 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2855 | { |
| 2856 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2857 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2858 | int i; |
| 2859 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2860 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2861 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2862 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2863 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2864 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2865 | snd_hda_codec_write(codec, nid, 0, |
| 2866 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2867 | AMP_OUT_MUTE); |
| 2868 | } |
| 2869 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2870 | |
| 2871 | /* mute all loopback inputs */ |
| 2872 | if (spec->mixer_nid) { |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2873 | int nums = snd_hda_get_num_conns(codec, spec->mixer_nid); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2874 | for (i = 0; i < nums; i++) |
| 2875 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2876 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2877 | AMP_IN_MUTE(i)); |
| 2878 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2879 | } |
| 2880 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2881 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2882 | { |
| 2883 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2884 | int i; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2885 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2886 | for (i = 0; i < spec->paths.used; i++) { |
| 2887 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2888 | if (path->path[0] == nid) |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2889 | return true; |
| 2890 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2891 | return false; |
| 2892 | } |
| 2893 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2894 | /* look for an empty DAC slot */ |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2895 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2896 | bool is_digital) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2897 | { |
| 2898 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2899 | bool cap_digital; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2900 | int i; |
| 2901 | |
| 2902 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2903 | hda_nid_t nid = spec->all_dacs[i]; |
| 2904 | if (!nid || alc_is_dac_already_used(codec, nid)) |
| 2905 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2906 | cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); |
| 2907 | if (is_digital != cap_digital) |
| 2908 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2909 | if (is_reachable_path(codec, nid, pin)) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2910 | return nid; |
| 2911 | } |
| 2912 | return 0; |
| 2913 | } |
| 2914 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2915 | /* called recursively */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2916 | static bool __parse_nid_path(struct hda_codec *codec, |
| 2917 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2918 | int with_aa_mix, struct nid_path *path, int depth) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2919 | { |
| 2920 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2921 | hda_nid_t conn[16]; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2922 | int i, nums; |
| 2923 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2924 | if (to_nid == spec->mixer_nid) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2925 | if (!with_aa_mix) |
| 2926 | return false; |
| 2927 | with_aa_mix = 2; /* mark aa-mix is included */ |
| 2928 | } |
| 2929 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2930 | nums = snd_hda_get_connections(codec, to_nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2931 | for (i = 0; i < nums; i++) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2932 | if (conn[i] != from_nid) { |
| 2933 | /* special case: when from_nid is 0, |
| 2934 | * try to find an empty DAC |
| 2935 | */ |
| 2936 | if (from_nid || |
| 2937 | get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || |
| 2938 | alc_is_dac_already_used(codec, conn[i])) |
| 2939 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2940 | } |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2941 | /* aa-mix is requested but not included? */ |
| 2942 | if (!(spec->mixer_nid && with_aa_mix == 1)) |
| 2943 | goto found; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2944 | } |
| 2945 | if (depth >= MAX_NID_PATH_DEPTH) |
| 2946 | return false; |
| 2947 | for (i = 0; i < nums; i++) { |
| 2948 | unsigned int type; |
| 2949 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2950 | if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN || |
| 2951 | type == AC_WID_PIN) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2952 | continue; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2953 | if (__parse_nid_path(codec, from_nid, conn[i], |
| 2954 | with_aa_mix, path, depth + 1)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2955 | goto found; |
| 2956 | } |
| 2957 | return false; |
| 2958 | |
| 2959 | found: |
| 2960 | path->path[path->depth] = conn[i]; |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2961 | path->idx[path->depth + 1] = i; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2962 | 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] | 2963 | path->multi[path->depth + 1] = 1; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2964 | path->depth++; |
| 2965 | return true; |
| 2966 | } |
| 2967 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2968 | /* parse the widget path from the given nid to the target nid; |
| 2969 | * when @from_nid is 0, try to find an empty DAC; |
| 2970 | * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded. |
| 2971 | * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded. |
| 2972 | * 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] | 2973 | */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2974 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2975 | hda_nid_t to_nid, int with_aa_mix, |
| 2976 | struct nid_path *path) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2977 | { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2978 | if (__parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path, 1)) { |
| 2979 | path->path[path->depth] = to_nid; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2980 | path->depth++; |
| 2981 | #if 0 |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2982 | snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n", |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2983 | path->depth, path->path[0], path->path[1], |
| 2984 | path->path[2], path->path[3], path->path[4]); |
| 2985 | #endif |
| 2986 | return true; |
| 2987 | } |
| 2988 | return false; |
| 2989 | } |
| 2990 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2991 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2992 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2993 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2994 | int i; |
| 2995 | hda_nid_t nid_found = 0; |
| 2996 | |
| 2997 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2998 | hda_nid_t nid = spec->all_dacs[i]; |
| 2999 | if (!nid || alc_is_dac_already_used(codec, nid)) |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3000 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3001 | if (is_reachable_path(codec, nid, pin)) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3002 | if (nid_found) |
| 3003 | return 0; |
| 3004 | nid_found = nid; |
| 3005 | } |
| 3006 | } |
| 3007 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3008 | } |
| 3009 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3010 | 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] | 3011 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3012 | struct alc_spec *spec = codec->spec; |
| 3013 | int i; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3014 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3015 | for (i = 0; i < spec->paths.used; i++) { |
| 3016 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3017 | if (path->ctls[type] == val) |
| 3018 | return true; |
| 3019 | } |
| 3020 | return false; |
| 3021 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3022 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3023 | /* badness definition */ |
| 3024 | enum { |
| 3025 | /* No primary DAC is found for the main output */ |
| 3026 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3027 | /* No DAC is found for the extra output */ |
| 3028 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3029 | /* No possible multi-ios */ |
| 3030 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3031 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3032 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3033 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3034 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3035 | /* Primary DAC shared with main surrounds */ |
| 3036 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3037 | /* Primary DAC shared with main CLFE */ |
| 3038 | BAD_SHARED_CLFE = 0x10, |
| 3039 | /* Primary DAC shared with extra surrounds */ |
| 3040 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3041 | /* Volume widget is shared */ |
| 3042 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3043 | }; |
| 3044 | |
| 3045 | 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] | 3046 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3047 | 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] | 3048 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3049 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3050 | static bool add_new_out_path(struct hda_codec *codec, hda_nid_t pin, |
| 3051 | hda_nid_t dac) |
| 3052 | { |
| 3053 | struct alc_spec *spec = codec->spec; |
| 3054 | struct nid_path *path; |
| 3055 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3056 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3057 | if (!path) |
| 3058 | return false; |
| 3059 | memset(path, 0, sizeof(*path)); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 3060 | if (parse_nid_path(codec, dac, pin, 0, path)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3061 | return true; |
| 3062 | /* push back */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3063 | spec->paths.used--; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3064 | return false; |
| 3065 | } |
| 3066 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3067 | /* get the path between the given NIDs; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3068 | * passing 0 to either @pin or @dac behaves as a wildcard |
| 3069 | */ |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3070 | static struct nid_path * |
| 3071 | 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] | 3072 | { |
| 3073 | struct alc_spec *spec = codec->spec; |
| 3074 | int i; |
| 3075 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3076 | for (i = 0; i < spec->paths.used; i++) { |
| 3077 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3078 | if (path->depth <= 0) |
| 3079 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3080 | if ((!from_nid || path->path[0] == from_nid) && |
| 3081 | (!to_nid || path->path[path->depth - 1] == to_nid)) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3082 | return path; |
| 3083 | } |
| 3084 | return NULL; |
| 3085 | } |
| 3086 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3087 | /* look for widgets in the path between the given NIDs appropriate for |
| 3088 | * volume and mute controls, and assign the values to ctls[]. |
| 3089 | * |
| 3090 | * When no appropriate widget is found in the path, the badness value |
| 3091 | * is incremented depending on the situation. The function returns the |
| 3092 | * total badness for both volume and mute controls. |
| 3093 | */ |
| 3094 | static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, |
| 3095 | hda_nid_t dac) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3096 | { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3097 | struct nid_path *path = get_nid_path(codec, dac, pin); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3098 | hda_nid_t nid; |
| 3099 | unsigned int val; |
| 3100 | int badness = 0; |
| 3101 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3102 | if (!path) |
| 3103 | return BAD_SHARED_VOL * 2; |
| 3104 | nid = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3105 | if (nid) { |
| 3106 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3107 | if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3108 | badness += BAD_SHARED_VOL; |
| 3109 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3110 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3111 | } else |
| 3112 | badness += BAD_SHARED_VOL; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3113 | nid = alc_look_for_out_mute_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3114 | if (nid) { |
| 3115 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3116 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT || |
| 3117 | nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3118 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3119 | else |
| 3120 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3121 | if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3122 | badness += BAD_SHARED_VOL; |
| 3123 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3124 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3125 | } else |
| 3126 | badness += BAD_SHARED_VOL; |
| 3127 | return badness; |
| 3128 | } |
| 3129 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3130 | struct badness_table { |
| 3131 | int no_primary_dac; /* no primary DAC */ |
| 3132 | int no_dac; /* no secondary DACs */ |
| 3133 | int shared_primary; /* primary DAC is shared with main output */ |
| 3134 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3135 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3136 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3137 | }; |
| 3138 | |
| 3139 | static struct badness_table main_out_badness = { |
| 3140 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3141 | .no_dac = BAD_NO_DAC, |
| 3142 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3143 | .shared_surr = BAD_SHARED_SURROUND, |
| 3144 | .shared_clfe = BAD_SHARED_CLFE, |
| 3145 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3146 | }; |
| 3147 | |
| 3148 | static struct badness_table extra_out_badness = { |
| 3149 | .no_primary_dac = BAD_NO_DAC, |
| 3150 | .no_dac = BAD_NO_DAC, |
| 3151 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3152 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3153 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3154 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3155 | }; |
| 3156 | |
| 3157 | /* try to assign DACs to pins and return the resultant badness */ |
| 3158 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3159 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3160 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3161 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3162 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3163 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3164 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3165 | int badness = 0; |
| 3166 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3167 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3168 | if (!num_outs) |
| 3169 | return 0; |
| 3170 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3171 | for (i = 0; i < num_outs; i++) { |
| 3172 | hda_nid_t pin = pins[i]; |
| 3173 | if (!dacs[i]) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 3174 | dacs[i] = alc_auto_look_for_dac(codec, pin, false); |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3175 | if (!dacs[i] && !i) { |
| 3176 | for (j = 1; j < num_outs; j++) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3177 | if (is_reachable_path(codec, dacs[j], pin)) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3178 | dacs[0] = dacs[j]; |
| 3179 | dacs[j] = 0; |
| 3180 | break; |
| 3181 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3182 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3183 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3184 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3185 | if (!dac) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3186 | if (is_reachable_path(codec, dacs[0], pin)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3187 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3188 | else if (cfg->line_outs > i && |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3189 | is_reachable_path(codec, spec->private_dac_nids[i], pin)) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3190 | dac = spec->private_dac_nids[i]; |
| 3191 | if (dac) { |
| 3192 | if (!i) |
| 3193 | badness += bad->shared_primary; |
| 3194 | else if (i == 1) |
| 3195 | badness += bad->shared_surr; |
| 3196 | else |
| 3197 | badness += bad->shared_clfe; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3198 | } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3199 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3200 | badness += bad->shared_surr_main; |
| 3201 | } else if (!i) |
| 3202 | badness += bad->no_primary_dac; |
| 3203 | else |
| 3204 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3205 | } |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3206 | if (!add_new_out_path(codec, pin, dac)) |
| 3207 | dac = dacs[i] = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3208 | if (dac) |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3209 | badness += assign_out_path_ctls(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3210 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3211 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3212 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3213 | } |
| 3214 | |
| 3215 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3216 | hda_nid_t reference_pin, |
| 3217 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3218 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3219 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3220 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3221 | { |
| 3222 | int i; |
| 3223 | bool found = false; |
| 3224 | for (i = 0; i < outs; i++) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3225 | hda_nid_t dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3226 | if (dacs[i]) |
| 3227 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3228 | dac = get_dac_if_single(codec, pins[i]); |
| 3229 | if (!dac) |
| 3230 | continue; |
| 3231 | if (add_new_out_path(codec, pins[i], dac)) { |
| 3232 | dacs[i] = dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3233 | found = true; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3234 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3235 | } |
| 3236 | return found; |
| 3237 | } |
| 3238 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3239 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3240 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3241 | bool fill_hardwired, |
| 3242 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3243 | { |
| 3244 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3245 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3246 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3247 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3248 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3249 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3250 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3251 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3252 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3253 | 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] | 3254 | spec->multi_ios = 0; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3255 | snd_array_free(&spec->paths); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3256 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3257 | |
| 3258 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3259 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3260 | bool mapped; |
| 3261 | do { |
| 3262 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3263 | cfg->line_out_pins, |
| 3264 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3265 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3266 | cfg->hp_pins, |
| 3267 | spec->multiout.hp_out_nid); |
| 3268 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3269 | cfg->speaker_pins, |
| 3270 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3271 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3272 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3273 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3274 | if (!err) |
| 3275 | mapped = true; |
| 3276 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3277 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3278 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3279 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3280 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3281 | spec->private_dac_nids, |
| 3282 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3283 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3284 | /* re-count num_dacs and squash invalid entries */ |
| 3285 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3286 | for (i = 0; i < cfg->line_outs; i++) { |
| 3287 | if (spec->private_dac_nids[i]) |
| 3288 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3289 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3290 | memmove(spec->private_dac_nids + i, |
| 3291 | spec->private_dac_nids + i + 1, |
| 3292 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3293 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3294 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3295 | } |
| 3296 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3297 | if (fill_mio_first && |
| 3298 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3299 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3300 | 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] | 3301 | if (err < 0) |
| 3302 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3303 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3304 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3305 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3306 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3307 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3308 | spec->multiout.hp_out_nid, |
| 3309 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3310 | if (err < 0) |
| 3311 | return err; |
| 3312 | badness += err; |
| 3313 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3314 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3315 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3316 | cfg->speaker_pins, |
| 3317 | spec->multiout.extra_out_nid, |
| 3318 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3319 | if (err < 0) |
| 3320 | return err; |
| 3321 | badness += err; |
| 3322 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3323 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3324 | 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] | 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->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3330 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3331 | int offset = 0; |
| 3332 | if (cfg->line_outs >= 3) |
| 3333 | offset = 1; |
| 3334 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3335 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3336 | if (err < 0) |
| 3337 | return err; |
| 3338 | badness += err; |
| 3339 | } |
| 3340 | |
| 3341 | if (spec->multi_ios == 2) { |
| 3342 | for (i = 0; i < 2; i++) |
| 3343 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3344 | spec->multi_io[i].dac; |
| 3345 | spec->ext_channel_count = 2; |
| 3346 | } else if (spec->multi_ios) { |
| 3347 | spec->multi_ios = 0; |
| 3348 | badness += BAD_MULTI_IO; |
| 3349 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3350 | |
| 3351 | return badness; |
| 3352 | } |
| 3353 | |
| 3354 | #define DEBUG_BADNESS |
| 3355 | |
| 3356 | #ifdef DEBUG_BADNESS |
| 3357 | #define debug_badness snd_printdd |
| 3358 | #else |
| 3359 | #define debug_badness(...) |
| 3360 | #endif |
| 3361 | |
| 3362 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3363 | { |
| 3364 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3365 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3366 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3367 | spec->multiout.dac_nids[0], |
| 3368 | spec->multiout.dac_nids[1], |
| 3369 | spec->multiout.dac_nids[2], |
| 3370 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3371 | if (spec->multi_ios > 0) |
| 3372 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3373 | spec->multi_ios, |
| 3374 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3375 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3376 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3377 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3378 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3379 | spec->multiout.hp_out_nid[0], |
| 3380 | spec->multiout.hp_out_nid[1], |
| 3381 | spec->multiout.hp_out_nid[2], |
| 3382 | spec->multiout.hp_out_nid[3]); |
| 3383 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3384 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3385 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3386 | spec->multiout.extra_out_nid[0], |
| 3387 | spec->multiout.extra_out_nid[1], |
| 3388 | spec->multiout.extra_out_nid[2], |
| 3389 | spec->multiout.extra_out_nid[3]); |
| 3390 | } |
| 3391 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3392 | /* find all available DACs of the codec */ |
| 3393 | static void alc_fill_all_nids(struct hda_codec *codec) |
| 3394 | { |
| 3395 | struct alc_spec *spec = codec->spec; |
| 3396 | int i; |
| 3397 | hda_nid_t nid = codec->start_nid; |
| 3398 | |
| 3399 | spec->num_all_dacs = 0; |
| 3400 | memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); |
| 3401 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 3402 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) |
| 3403 | continue; |
| 3404 | if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { |
| 3405 | snd_printk(KERN_ERR "hda: Too many DACs!\n"); |
| 3406 | break; |
| 3407 | } |
| 3408 | spec->all_dacs[spec->num_all_dacs++] = nid; |
| 3409 | } |
| 3410 | } |
| 3411 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3412 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3413 | { |
| 3414 | struct alc_spec *spec = codec->spec; |
| 3415 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3416 | struct auto_pin_cfg *best_cfg; |
| 3417 | int best_badness = INT_MAX; |
| 3418 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3419 | bool fill_hardwired = true, fill_mio_first = true; |
| 3420 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3421 | bool hp_spk_swapped = false; |
| 3422 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3423 | alc_fill_all_nids(codec); |
| 3424 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3425 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3426 | if (!best_cfg) |
| 3427 | return -ENOMEM; |
| 3428 | *best_cfg = *cfg; |
| 3429 | |
| 3430 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3431 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3432 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3433 | if (badness < 0) { |
| 3434 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3435 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3436 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3437 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3438 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3439 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3440 | debug_show_configs(spec, cfg); |
| 3441 | if (badness < best_badness) { |
| 3442 | best_badness = badness; |
| 3443 | *best_cfg = *cfg; |
| 3444 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3445 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3446 | } |
| 3447 | if (!badness) |
| 3448 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3449 | fill_mio_first = !fill_mio_first; |
| 3450 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3451 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3452 | fill_hardwired = !fill_hardwired; |
| 3453 | if (!fill_hardwired) |
| 3454 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3455 | if (hp_spk_swapped) |
| 3456 | break; |
| 3457 | hp_spk_swapped = true; |
| 3458 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3459 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3460 | cfg->hp_outs = cfg->line_outs; |
| 3461 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3462 | sizeof(cfg->hp_pins)); |
| 3463 | cfg->line_outs = cfg->speaker_outs; |
| 3464 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3465 | sizeof(cfg->speaker_pins)); |
| 3466 | cfg->speaker_outs = 0; |
| 3467 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3468 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3469 | fill_hardwired = true; |
| 3470 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3471 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3472 | if (cfg->hp_outs > 0 && |
| 3473 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3474 | cfg->speaker_outs = cfg->line_outs; |
| 3475 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3476 | sizeof(cfg->speaker_pins)); |
| 3477 | cfg->line_outs = cfg->hp_outs; |
| 3478 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3479 | sizeof(cfg->hp_pins)); |
| 3480 | cfg->hp_outs = 0; |
| 3481 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3482 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3483 | fill_hardwired = true; |
| 3484 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3485 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3486 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3487 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3488 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3489 | if (badness) { |
| 3490 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3491 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3492 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3493 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3494 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3495 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3496 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3497 | if (cfg->line_out_pins[0]) { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3498 | struct nid_path *path = get_nid_path(codec, |
| 3499 | spec->multiout.dac_nids[0], |
| 3500 | cfg->line_out_pins[0]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3501 | if (path) |
| 3502 | spec->vmaster_nid = alc_look_for_out_vol_nid(codec, path); |
| 3503 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3504 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3505 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3506 | return 0; |
| 3507 | } |
| 3508 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3509 | /* replace the channels in the composed amp value with the given number */ |
| 3510 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) |
| 3511 | { |
| 3512 | val &= ~(0x3U << 16); |
| 3513 | val |= chs << 16; |
| 3514 | return val; |
| 3515 | } |
| 3516 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3517 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3518 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3519 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3520 | struct nid_path *path) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3521 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3522 | unsigned int val; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3523 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3524 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3525 | val = path->ctls[NID_PATH_VOL_CTL]; |
| 3526 | if (!val) |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3527 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3528 | val = amp_val_replace_channels(val, chs); |
| 3529 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, val); |
| 3530 | } |
| 3531 | |
| 3532 | /* return the channel bits suitable for the given path->ctls[] */ |
| 3533 | static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, |
| 3534 | int type) |
| 3535 | { |
| 3536 | int chs = 1; /* mono (left only) */ |
| 3537 | if (path) { |
| 3538 | hda_nid_t nid = get_amp_nid_(path->ctls[type]); |
| 3539 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) |
| 3540 | chs = 3; /* stereo */ |
| 3541 | } |
| 3542 | return chs; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3543 | } |
| 3544 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3545 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3546 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3547 | struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3548 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3549 | int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); |
| 3550 | return alc_auto_add_vol_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3551 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3552 | |
| 3553 | /* create a mute-switch for the given mixer widget; |
| 3554 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3555 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3556 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3557 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3558 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3559 | struct nid_path *path) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3560 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3561 | unsigned int val; |
| 3562 | int type = ALC_CTL_WIDGET_MUTE; |
| 3563 | |
| 3564 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3565 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3566 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 3567 | if (!val) |
| 3568 | return 0; |
| 3569 | val = amp_val_replace_channels(val, chs); |
| 3570 | if (get_amp_direction_(val) == HDA_INPUT) { |
| 3571 | hda_nid_t nid = get_amp_nid_(val); |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3572 | int nums = snd_hda_get_num_conns(codec, nid); |
| 3573 | if (nums > 1) { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3574 | type = ALC_CTL_BIND_MUTE; |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3575 | val |= nums << 19; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3576 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3577 | } |
| 3578 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3579 | } |
| 3580 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3581 | 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] | 3582 | int cidx, struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3583 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3584 | int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); |
| 3585 | return alc_auto_add_sw_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3586 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3587 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3588 | 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] | 3589 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3590 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3591 | int i; |
| 3592 | |
| 3593 | for (i = path->depth - 1; i >= 0; i--) { |
| 3594 | if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) |
| 3595 | return path->path[i]; |
| 3596 | if (i != path->depth - 1 && i != 0 && |
| 3597 | nid_has_mute(codec, path->path[i], HDA_INPUT)) |
| 3598 | return path->path[i]; |
| 3599 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3600 | return 0; |
| 3601 | } |
| 3602 | |
| 3603 | 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] | 3604 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3605 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3606 | int i; |
| 3607 | |
| 3608 | for (i = path->depth - 1; i >= 0; i--) { |
| 3609 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) |
| 3610 | return path->path[i]; |
| 3611 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3612 | return 0; |
| 3613 | } |
| 3614 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3615 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3616 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3617 | const struct auto_pin_cfg *cfg) |
| 3618 | { |
| 3619 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3620 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3621 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3622 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3623 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3624 | noutputs += spec->multi_ios; |
| 3625 | |
| 3626 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3627 | const char *name; |
| 3628 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3629 | hda_nid_t dac, pin; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3630 | struct nid_path *path; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3631 | |
| 3632 | dac = spec->multiout.dac_nids[i]; |
| 3633 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3634 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3635 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3636 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3637 | index = 0; |
| 3638 | name = channel_name[i]; |
| 3639 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3640 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3641 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3642 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3643 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3644 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3645 | if (!path) |
| 3646 | continue; |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3647 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3648 | /* Center/LFE */ |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3649 | err = alc_auto_add_vol_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3650 | if (err < 0) |
| 3651 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3652 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3653 | if (err < 0) |
| 3654 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3655 | err = alc_auto_add_sw_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_sw_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; |
| 3661 | } else { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3662 | err = alc_auto_add_stereo_vol(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3663 | if (err < 0) |
| 3664 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3665 | err = alc_auto_add_stereo_sw(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3666 | if (err < 0) |
| 3667 | return err; |
| 3668 | } |
| 3669 | } |
| 3670 | return 0; |
| 3671 | } |
| 3672 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3673 | 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] | 3674 | hda_nid_t dac, const char *pfx, |
| 3675 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3676 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3677 | struct nid_path *path; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3678 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3679 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3680 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3681 | if (!path) |
| 3682 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3683 | /* bind volume control will be created in the case of dac = 0 */ |
| 3684 | if (dac) { |
| 3685 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, path); |
| 3686 | if (err < 0) |
| 3687 | return err; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3688 | } |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3689 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, path); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3690 | if (err < 0) |
| 3691 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3692 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3693 | } |
| 3694 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3695 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3696 | unsigned int nums, |
| 3697 | struct hda_ctl_ops *ops) |
| 3698 | { |
| 3699 | struct alc_spec *spec = codec->spec; |
| 3700 | struct hda_bind_ctls **ctlp, *ctl; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3701 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3702 | if (!ctlp) |
| 3703 | return NULL; |
| 3704 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3705 | *ctlp = ctl; |
| 3706 | if (ctl) |
| 3707 | ctl->ops = ops; |
| 3708 | return ctl; |
| 3709 | } |
| 3710 | |
| 3711 | /* add playback controls for speaker and HP outputs */ |
| 3712 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3713 | const hda_nid_t *pins, |
| 3714 | const hda_nid_t *dacs, |
| 3715 | const char *pfx) |
| 3716 | { |
| 3717 | struct alc_spec *spec = codec->spec; |
| 3718 | struct hda_bind_ctls *ctl; |
| 3719 | char name[32]; |
| 3720 | int i, n, err; |
| 3721 | |
| 3722 | if (!num_pins || !pins[0]) |
| 3723 | return 0; |
| 3724 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3725 | if (num_pins == 1) { |
| 3726 | hda_nid_t dac = *dacs; |
| 3727 | if (!dac) |
| 3728 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3729 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3730 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3731 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3732 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3733 | hda_nid_t dac; |
| 3734 | if (dacs[num_pins - 1]) |
| 3735 | dac = dacs[i]; /* with individual volumes */ |
| 3736 | else |
| 3737 | dac = 0; |
| 3738 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3739 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3740 | "Bass Speaker", 0); |
| 3741 | } else if (num_pins >= 3) { |
| 3742 | snprintf(name, sizeof(name), "%s %s", |
| 3743 | pfx, channel_name[i]); |
| 3744 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3745 | name, 0); |
| 3746 | } else { |
| 3747 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3748 | pfx, i); |
| 3749 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3750 | if (err < 0) |
| 3751 | return err; |
| 3752 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3753 | if (dacs[num_pins - 1]) |
| 3754 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3755 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3756 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3757 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3758 | if (!ctl) |
| 3759 | return -ENOMEM; |
| 3760 | n = 0; |
| 3761 | for (i = 0; i < num_pins; i++) { |
| 3762 | hda_nid_t vol; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3763 | struct nid_path *path; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3764 | if (!pins[i] || !dacs[i]) |
| 3765 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3766 | path = get_nid_path(codec, dacs[i], pins[i]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3767 | if (!path) |
| 3768 | continue; |
| 3769 | vol = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3770 | if (vol) |
| 3771 | ctl->values[n++] = |
| 3772 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3773 | } |
| 3774 | if (n) { |
| 3775 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3776 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3777 | if (err < 0) |
| 3778 | return err; |
| 3779 | } |
| 3780 | return 0; |
| 3781 | } |
| 3782 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3783 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3784 | { |
| 3785 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3786 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3787 | spec->autocfg.hp_pins, |
| 3788 | spec->multiout.hp_out_nid, |
| 3789 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3790 | } |
| 3791 | |
| 3792 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3793 | { |
| 3794 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3795 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3796 | spec->autocfg.speaker_pins, |
| 3797 | spec->multiout.extra_out_nid, |
| 3798 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3799 | } |
| 3800 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3801 | /* check whether a control with the given (nid, dir, idx) was assigned */ |
| 3802 | static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, |
| 3803 | int dir, int idx) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3804 | { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3805 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3806 | int i, type; |
| 3807 | |
| 3808 | for (i = 0; i < spec->paths.used; i++) { |
| 3809 | struct nid_path *p = snd_array_elem(&spec->paths, i); |
| 3810 | if (p->depth <= 0) |
| 3811 | continue; |
| 3812 | for (type = 0; type < 2; type++) { |
| 3813 | unsigned int val = p->ctls[type]; |
| 3814 | if (get_amp_nid_(val) == nid && |
| 3815 | get_amp_direction_(val) == dir && |
| 3816 | get_amp_index_(val) == idx) |
| 3817 | return true; |
| 3818 | } |
| 3819 | } |
| 3820 | return false; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3821 | } |
| 3822 | |
| 3823 | /* can have the amp-in capability? */ |
| 3824 | static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3825 | { |
| 3826 | hda_nid_t nid = path->path[idx]; |
| 3827 | unsigned int caps = get_wcaps(codec, nid); |
| 3828 | unsigned int type = get_wcaps_type(caps); |
| 3829 | |
| 3830 | if (!(caps & AC_WCAP_IN_AMP)) |
| 3831 | return false; |
| 3832 | if (type == AC_WID_PIN && idx > 0) /* only for input pins */ |
| 3833 | return false; |
| 3834 | return true; |
| 3835 | } |
| 3836 | |
| 3837 | /* can have the amp-out capability? */ |
| 3838 | static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3839 | { |
| 3840 | hda_nid_t nid = path->path[idx]; |
| 3841 | unsigned int caps = get_wcaps(codec, nid); |
| 3842 | unsigned int type = get_wcaps_type(caps); |
| 3843 | |
| 3844 | if (!(caps & AC_WCAP_OUT_AMP)) |
| 3845 | return false; |
| 3846 | if (type == AC_WID_PIN && !idx) /* only for output pins */ |
| 3847 | return false; |
| 3848 | return true; |
| 3849 | } |
| 3850 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3851 | /* check whether the given (nid,dir,idx) is active */ |
| 3852 | static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, |
| 3853 | unsigned int idx, unsigned int dir) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3854 | { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3855 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3856 | int i, n; |
| 3857 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3858 | for (n = 0; n < spec->paths.used; n++) { |
| 3859 | struct nid_path *path = snd_array_elem(&spec->paths, n); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3860 | if (!path->active) |
| 3861 | continue; |
| 3862 | for (i = 0; i < path->depth; i++) { |
| 3863 | if (path->path[i] == nid) { |
| 3864 | if (dir == HDA_OUTPUT || path->idx[i] == idx) |
| 3865 | return true; |
| 3866 | break; |
| 3867 | } |
| 3868 | } |
| 3869 | } |
| 3870 | return false; |
| 3871 | } |
| 3872 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3873 | /* get the default amp value for the target state */ |
| 3874 | static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, |
| 3875 | int dir, bool enable) |
| 3876 | { |
| 3877 | unsigned int caps; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3878 | unsigned int val = 0; |
| 3879 | |
| 3880 | caps = query_amp_caps(codec, nid, dir); |
| 3881 | if (caps & AC_AMPCAP_NUM_STEPS) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3882 | /* set to 0dB */ |
| 3883 | if (enable) |
| 3884 | val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3885 | } |
| 3886 | if (caps & AC_AMPCAP_MUTE) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3887 | if (!enable) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3888 | val |= HDA_AMP_MUTE; |
| 3889 | } |
| 3890 | return val; |
| 3891 | } |
| 3892 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3893 | /* initialize the amp value (only at the first time) */ |
| 3894 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
| 3895 | { |
| 3896 | int val = get_amp_val_to_activate(codec, nid, dir, false); |
| 3897 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); |
| 3898 | } |
| 3899 | |
| 3900 | static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 3901 | int idx, bool enable) |
| 3902 | { |
| 3903 | int val; |
| 3904 | if (is_ctl_associated(codec, nid, dir, idx) || |
| 3905 | is_active_nid(codec, nid, dir, idx)) |
| 3906 | return; |
| 3907 | val = get_amp_val_to_activate(codec, nid, dir, enable); |
| 3908 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, 0xff, val); |
| 3909 | } |
| 3910 | |
| 3911 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
| 3912 | int i, bool enable) |
| 3913 | { |
| 3914 | hda_nid_t nid = path->path[i]; |
| 3915 | init_amp(codec, nid, HDA_OUTPUT, 0); |
| 3916 | activate_amp(codec, nid, HDA_OUTPUT, 0, enable); |
| 3917 | } |
| 3918 | |
| 3919 | static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, |
| 3920 | int i, bool enable) |
| 3921 | { |
| 3922 | struct alc_spec *spec = codec->spec; |
| 3923 | hda_nid_t conn[16]; |
| 3924 | int n, nums; |
| 3925 | hda_nid_t nid = path->path[i]; |
| 3926 | |
| 3927 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
| 3928 | for (n = 0; n < nums; n++) |
| 3929 | init_amp(codec, nid, HDA_INPUT, n); |
| 3930 | |
| 3931 | if (is_ctl_associated(codec, nid, HDA_INPUT, path->idx[i])) |
| 3932 | return; |
| 3933 | |
| 3934 | /* here is a little bit tricky in comparison with activate_amp_out(); |
| 3935 | * when aa-mixer is available, we need to enable the path as well |
| 3936 | */ |
| 3937 | for (n = 0; n < nums; n++) { |
| 3938 | if (n != path->idx[i] && conn[n] != spec->mixer_nid) |
| 3939 | continue; |
| 3940 | activate_amp(codec, nid, HDA_INPUT, n, enable); |
| 3941 | } |
| 3942 | } |
| 3943 | |
| 3944 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 3945 | bool enable) |
| 3946 | { |
| 3947 | int i; |
| 3948 | |
| 3949 | if (path->active == enable) |
| 3950 | return; |
| 3951 | |
| 3952 | if (!enable) |
| 3953 | path->active = false; |
| 3954 | |
| 3955 | for (i = path->depth - 1; i >= 0; i--) { |
| 3956 | if (path->multi[i]) |
| 3957 | snd_hda_codec_write_cache(codec, path->path[i], 0, |
| 3958 | AC_VERB_SET_CONNECT_SEL, |
| 3959 | path->idx[i]); |
| 3960 | if (has_amp_in(codec, path, i)) |
| 3961 | activate_amp_in(codec, path, i, enable); |
| 3962 | if (has_amp_out(codec, path, i)) |
| 3963 | activate_amp_out(codec, path, i, enable); |
| 3964 | } |
| 3965 | |
| 3966 | if (enable) |
| 3967 | path->active = true; |
| 3968 | } |
| 3969 | |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3970 | /* configure the path from the given dac to the pin as the proper output */ |
| 3971 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3972 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3973 | hda_nid_t dac) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3974 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3975 | struct nid_path *path; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3976 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3977 | snd_hda_set_pin_ctl_cache(codec, pin, pin_type); |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 3978 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3979 | if (!path) |
| 3980 | return; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3981 | activate_path(codec, path, true); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3982 | } |
| 3983 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3984 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3985 | { |
| 3986 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3987 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3988 | int i; |
| 3989 | |
| 3990 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3991 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3992 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3993 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3994 | spec->multiout.dac_nids[i]); |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3995 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3996 | } |
| 3997 | } |
| 3998 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3999 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4000 | { |
| 4001 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4002 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4003 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4004 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 4005 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4006 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 4007 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 4008 | pin = spec->autocfg.hp_pins[i]; |
| 4009 | if (!pin) |
| 4010 | break; |
| 4011 | dac = spec->multiout.hp_out_nid[i]; |
| 4012 | if (!dac) { |
| 4013 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 4014 | dac = spec->multiout.hp_out_nid[0]; |
| 4015 | else |
| 4016 | dac = spec->multiout.dac_nids[0]; |
| 4017 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4018 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4019 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4020 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4021 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4022 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4023 | pin = spec->autocfg.speaker_pins[i]; |
| 4024 | if (!pin) |
| 4025 | break; |
| 4026 | dac = spec->multiout.extra_out_nid[i]; |
| 4027 | if (!dac) { |
| 4028 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 4029 | dac = spec->multiout.extra_out_nid[0]; |
| 4030 | else |
| 4031 | dac = spec->multiout.dac_nids[0]; |
| 4032 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4033 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4034 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4035 | } |
| 4036 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4037 | /* check whether the given pin can be a multi-io pin */ |
| 4038 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 4039 | unsigned int location, hda_nid_t nid) |
| 4040 | { |
| 4041 | unsigned int defcfg, caps; |
| 4042 | |
| 4043 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 4044 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 4045 | return false; |
| 4046 | if (location && get_defcfg_location(defcfg) != location) |
| 4047 | return false; |
| 4048 | caps = snd_hda_query_pin_caps(codec, nid); |
| 4049 | if (!(caps & AC_PINCAP_OUT)) |
| 4050 | return false; |
| 4051 | return true; |
| 4052 | } |
| 4053 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4054 | /* |
| 4055 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4056 | * |
| 4057 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 4058 | * zero if any pins are filled, non-zero if nothing found. |
| 4059 | * When hardwired is off, try to fill possible input pins, and returns |
| 4060 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4061 | */ |
| 4062 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4063 | hda_nid_t reference_pin, |
| 4064 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4065 | { |
| 4066 | struct alc_spec *spec = codec->spec; |
| 4067 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4068 | int type, i, j, dacs, num_pins, old_pins; |
| 4069 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 4070 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4071 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4072 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4073 | old_pins = spec->multi_ios; |
| 4074 | if (old_pins >= 2) |
| 4075 | goto end_fill; |
| 4076 | |
| 4077 | num_pins = 0; |
| 4078 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4079 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4080 | if (cfg->inputs[i].type != type) |
| 4081 | continue; |
| 4082 | if (can_be_multiio_pin(codec, location, |
| 4083 | cfg->inputs[i].pin)) |
| 4084 | num_pins++; |
| 4085 | } |
| 4086 | } |
| 4087 | if (num_pins < 2) |
| 4088 | goto end_fill; |
| 4089 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4090 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4091 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4092 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4093 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4094 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4095 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4096 | if (cfg->inputs[i].type != type) |
| 4097 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4098 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4099 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4100 | for (j = 0; j < spec->multi_ios; j++) { |
| 4101 | if (nid == spec->multi_io[j].pin) |
| 4102 | break; |
| 4103 | } |
| 4104 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4105 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4106 | |
| 4107 | if (offset && offset + spec->multi_ios < dacs) { |
| 4108 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 4109 | if (!is_reachable_path(codec, dac, nid)) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4110 | dac = 0; |
| 4111 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4112 | if (hardwired) |
| 4113 | dac = get_dac_if_single(codec, nid); |
| 4114 | else if (!dac) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 4115 | dac = alc_auto_look_for_dac(codec, nid, false); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4116 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4117 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4118 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4119 | } |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4120 | if (!add_new_out_path(codec, nid, dac)) { |
| 4121 | badness++; |
| 4122 | continue; |
| 4123 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4124 | spec->multi_io[spec->multi_ios].pin = nid; |
| 4125 | spec->multi_io[spec->multi_ios].dac = dac; |
| 4126 | spec->multi_ios++; |
| 4127 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4128 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4129 | } |
| 4130 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4131 | end_fill: |
| 4132 | if (badness) |
| 4133 | badness = BAD_MULTI_IO; |
| 4134 | if (old_pins == spec->multi_ios) { |
| 4135 | if (hardwired) |
| 4136 | return 1; /* nothing found */ |
| 4137 | else |
| 4138 | return badness; /* no badness if nothing found */ |
| 4139 | } |
| 4140 | if (!hardwired && spec->multi_ios < 2) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4141 | /* cancel newly assigned paths */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4142 | spec->paths.used -= spec->multi_ios - old_pins; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4143 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4144 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4145 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4146 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 4147 | /* assign volume and mute controls */ |
| 4148 | for (i = old_pins; i < spec->multi_ios; i++) |
| 4149 | badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, |
| 4150 | spec->multi_io[i].dac); |
| 4151 | |
| 4152 | return badness; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4153 | } |
| 4154 | |
| 4155 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 4156 | struct snd_ctl_elem_info *uinfo) |
| 4157 | { |
| 4158 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4159 | struct alc_spec *spec = codec->spec; |
| 4160 | |
| 4161 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 4162 | uinfo->count = 1; |
| 4163 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 4164 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 4165 | uinfo->value.enumerated.item = spec->multi_ios; |
| 4166 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 4167 | (uinfo->value.enumerated.item + 1) * 2); |
| 4168 | return 0; |
| 4169 | } |
| 4170 | |
| 4171 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 4172 | struct snd_ctl_elem_value *ucontrol) |
| 4173 | { |
| 4174 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4175 | struct alc_spec *spec = codec->spec; |
| 4176 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 4177 | return 0; |
| 4178 | } |
| 4179 | |
| 4180 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 4181 | { |
| 4182 | struct alc_spec *spec = codec->spec; |
| 4183 | hda_nid_t nid = spec->multi_io[idx].pin; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4184 | struct nid_path *path; |
| 4185 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame^] | 4186 | path = get_nid_path(codec, spec->multi_io[idx].dac, nid); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4187 | if (!path) |
| 4188 | return -EINVAL; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4189 | |
| 4190 | if (!spec->multi_io[idx].ctl_in) |
| 4191 | spec->multi_io[idx].ctl_in = |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4192 | snd_hda_codec_update_cache(codec, nid, 0, |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4193 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4194 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4195 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4196 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4197 | activate_path(codec, path, true); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4198 | } else { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4199 | activate_path(codec, path, false); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4200 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4201 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4202 | } |
| 4203 | return 0; |
| 4204 | } |
| 4205 | |
| 4206 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4207 | struct snd_ctl_elem_value *ucontrol) |
| 4208 | { |
| 4209 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4210 | struct alc_spec *spec = codec->spec; |
| 4211 | int i, ch; |
| 4212 | |
| 4213 | ch = ucontrol->value.enumerated.item[0]; |
| 4214 | if (ch < 0 || ch > spec->multi_ios) |
| 4215 | return -EINVAL; |
| 4216 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4217 | return 0; |
| 4218 | spec->ext_channel_count = (ch + 1) * 2; |
| 4219 | for (i = 0; i < spec->multi_ios; i++) |
| 4220 | alc_set_multi_io(codec, i, i < ch); |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4221 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4222 | spec->const_channel_count); |
| 4223 | if (spec->need_dac_fix) |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4224 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4225 | return 1; |
| 4226 | } |
| 4227 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4228 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4229 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4230 | .name = "Channel Mode", |
| 4231 | .info = alc_auto_ch_mode_info, |
| 4232 | .get = alc_auto_ch_mode_get, |
| 4233 | .put = alc_auto_ch_mode_put, |
| 4234 | }; |
| 4235 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4236 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4237 | { |
| 4238 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4239 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4240 | if (spec->multi_ios > 0) { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 4241 | if (!alc_kcontrol_new(spec, "Channel Mode", |
| 4242 | &alc_auto_channel_mode_enum)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4243 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4244 | } |
| 4245 | return 0; |
| 4246 | } |
| 4247 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4248 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 4249 | * active input pins |
| 4250 | */ |
| 4251 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 4252 | { |
| 4253 | struct alc_spec *spec = codec->spec; |
| 4254 | const struct hda_input_mux *imux; |
| 4255 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4256 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4257 | int i, n, nums; |
| 4258 | |
| 4259 | imux = spec->input_mux; |
| 4260 | if (!imux) |
| 4261 | return; |
| 4262 | if (spec->dyn_adc_switch) |
| 4263 | return; |
| 4264 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4265 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4266 | nums = 0; |
| 4267 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 4268 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 4269 | int num_conns = snd_hda_get_num_conns(codec, cap); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4270 | for (i = 0; i < imux->num_items; i++) { |
| 4271 | hda_nid_t pin = spec->imux_pins[i]; |
| 4272 | if (pin) { |
| 4273 | if (get_connection_index(codec, cap, pin) < 0) |
| 4274 | break; |
| 4275 | } else if (num_conns <= imux->items[i].index) |
| 4276 | break; |
| 4277 | } |
| 4278 | if (i >= imux->num_items) { |
| 4279 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 4280 | capsrc_nids[nums++] = cap; |
| 4281 | } |
| 4282 | } |
| 4283 | if (!nums) { |
| 4284 | /* check whether ADC-switch is possible */ |
| 4285 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4286 | if (spec->shared_mic_hp) { |
| 4287 | spec->shared_mic_hp = 0; |
| 4288 | spec->private_imux[0].num_items = 1; |
| 4289 | goto again; |
| 4290 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4291 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 4292 | " using fallback 0x%x\n", |
| 4293 | codec->chip_name, spec->private_adc_nids[0]); |
| 4294 | spec->num_adc_nids = 1; |
| 4295 | spec->auto_mic = 0; |
| 4296 | return; |
| 4297 | } |
| 4298 | } else if (nums != spec->num_adc_nids) { |
| 4299 | memcpy(spec->private_adc_nids, adc_nids, |
| 4300 | nums * sizeof(hda_nid_t)); |
| 4301 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 4302 | nums * sizeof(hda_nid_t)); |
| 4303 | spec->num_adc_nids = nums; |
| 4304 | } |
| 4305 | |
| 4306 | if (spec->auto_mic) |
| 4307 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4308 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4309 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 4310 | } |
| 4311 | |
| 4312 | /* |
| 4313 | * initialize ADC paths |
| 4314 | */ |
| 4315 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 4316 | { |
| 4317 | struct alc_spec *spec = codec->spec; |
| 4318 | hda_nid_t nid; |
| 4319 | |
| 4320 | nid = spec->adc_nids[adc_idx]; |
| 4321 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4322 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4323 | snd_hda_codec_write(codec, nid, 0, |
| 4324 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4325 | AMP_IN_MUTE(0)); |
| 4326 | return; |
| 4327 | } |
| 4328 | if (!spec->capsrc_nids) |
| 4329 | return; |
| 4330 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4331 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4332 | snd_hda_codec_write(codec, nid, 0, |
| 4333 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4334 | AMP_OUT_MUTE); |
| 4335 | } |
| 4336 | |
| 4337 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4338 | { |
| 4339 | struct alc_spec *spec = codec->spec; |
| 4340 | int c, nums; |
| 4341 | |
| 4342 | for (c = 0; c < spec->num_adc_nids; c++) |
| 4343 | alc_auto_init_adc(codec, c); |
| 4344 | if (spec->dyn_adc_switch) |
| 4345 | nums = 1; |
| 4346 | else |
| 4347 | nums = spec->num_adc_nids; |
| 4348 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 4349 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4350 | } |
| 4351 | |
| 4352 | /* add mic boosts if needed */ |
| 4353 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4354 | { |
| 4355 | struct alc_spec *spec = codec->spec; |
| 4356 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4357 | int i, err; |
| 4358 | int type_idx = 0; |
| 4359 | hda_nid_t nid; |
| 4360 | const char *prev_label = NULL; |
| 4361 | |
| 4362 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4363 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4364 | break; |
| 4365 | nid = cfg->inputs[i].pin; |
| 4366 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4367 | const char *label; |
| 4368 | char boost_label[32]; |
| 4369 | |
| 4370 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4371 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4372 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4373 | if (prev_label && !strcmp(label, prev_label)) |
| 4374 | type_idx++; |
| 4375 | else |
| 4376 | type_idx = 0; |
| 4377 | prev_label = label; |
| 4378 | |
| 4379 | snprintf(boost_label, sizeof(boost_label), |
| 4380 | "%s Boost Volume", label); |
| 4381 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 4382 | boost_label, type_idx, |
| 4383 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 4384 | if (err < 0) |
| 4385 | return err; |
| 4386 | } |
| 4387 | } |
| 4388 | return 0; |
| 4389 | } |
| 4390 | |
| 4391 | /* select or unmute the given capsrc route */ |
| 4392 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4393 | int idx) |
| 4394 | { |
| 4395 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4396 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4397 | HDA_AMP_MUTE, 0); |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 4398 | } else if (snd_hda_get_num_conns(codec, cap) > 1) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4399 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4400 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4401 | } |
| 4402 | } |
| 4403 | |
| 4404 | /* set the default connection to that pin */ |
| 4405 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4406 | { |
| 4407 | struct alc_spec *spec = codec->spec; |
| 4408 | int i; |
| 4409 | |
| 4410 | if (!pin) |
| 4411 | return 0; |
| 4412 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4413 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4414 | int idx; |
| 4415 | |
| 4416 | idx = get_connection_index(codec, cap, pin); |
| 4417 | if (idx < 0) |
| 4418 | continue; |
| 4419 | select_or_unmute_capsrc(codec, cap, idx); |
| 4420 | return i; /* return the found index */ |
| 4421 | } |
| 4422 | return -1; /* not found */ |
| 4423 | } |
| 4424 | |
| 4425 | /* initialize some special cases for input sources */ |
| 4426 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4427 | { |
| 4428 | struct alc_spec *spec = codec->spec; |
| 4429 | int i; |
| 4430 | |
| 4431 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4432 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4433 | } |
| 4434 | |
| 4435 | /* assign appropriate capture mixers */ |
| 4436 | static void set_capture_mixer(struct hda_codec *codec) |
| 4437 | { |
| 4438 | struct alc_spec *spec = codec->spec; |
| 4439 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4440 | { alc_capture_mixer_nosrc1, |
| 4441 | alc_capture_mixer_nosrc2, |
| 4442 | alc_capture_mixer_nosrc3 }, |
| 4443 | { alc_capture_mixer1, |
| 4444 | alc_capture_mixer2, |
| 4445 | alc_capture_mixer3 }, |
| 4446 | }; |
| 4447 | |
| 4448 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4449 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4450 | if (!spec->capsrc_nids) |
| 4451 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4452 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4453 | return; /* no volume in capsrc, too */ |
| 4454 | spec->vol_in_capsrc = 1; |
| 4455 | } |
| 4456 | |
| 4457 | if (spec->num_adc_nids > 0) { |
| 4458 | int mux = 0; |
| 4459 | int num_adcs = 0; |
| 4460 | |
| 4461 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4462 | mux = 1; |
| 4463 | if (spec->auto_mic) { |
| 4464 | num_adcs = 1; |
| 4465 | mux = 0; |
| 4466 | } else if (spec->dyn_adc_switch) |
| 4467 | num_adcs = 1; |
| 4468 | if (!num_adcs) { |
| 4469 | if (spec->num_adc_nids > 3) |
| 4470 | spec->num_adc_nids = 3; |
| 4471 | else if (!spec->num_adc_nids) |
| 4472 | return; |
| 4473 | num_adcs = spec->num_adc_nids; |
| 4474 | } |
| 4475 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4476 | } |
| 4477 | } |
| 4478 | |
| 4479 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4480 | * standard auto-parser initializations |
| 4481 | */ |
| 4482 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4483 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4484 | alc_auto_init_multi_out(codec); |
| 4485 | alc_auto_init_extra_out(codec); |
| 4486 | alc_auto_init_analog_input(codec); |
| 4487 | alc_auto_init_input_src(codec); |
| 4488 | alc_auto_init_digital(codec); |
David Henningsson | a7a0a64 | 2012-07-05 12:00:12 +0200 | [diff] [blame] | 4489 | alc_inithook(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4490 | } |
| 4491 | |
| 4492 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4493 | * Digital-beep handlers |
| 4494 | */ |
| 4495 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4496 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4497 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4498 | |
| 4499 | static const struct snd_pci_quirk beep_white_list[] = { |
Duncan Roe | 7110005 | 2012-10-10 14:19:50 +0200 | [diff] [blame] | 4500 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4501 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4502 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4503 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4504 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4505 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4506 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4507 | {} |
| 4508 | }; |
| 4509 | |
| 4510 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4511 | { |
| 4512 | struct alc_spec *spec = codec->spec; |
| 4513 | const struct snd_pci_quirk *q; |
| 4514 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4515 | if (q) |
| 4516 | return q->value; |
| 4517 | return spec->cdefine.enable_pcbeep; |
| 4518 | } |
| 4519 | #else |
| 4520 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4521 | #define has_cdefine_beep(codec) 0 |
| 4522 | #endif |
| 4523 | |
| 4524 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4525 | /* return 1 if successful, 0 if the proper config is not found, |
| 4526 | * or a negative error code |
| 4527 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4528 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4529 | const hda_nid_t *ignore_nids, |
| 4530 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4531 | { |
| 4532 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4533 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4534 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4535 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4536 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4537 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4538 | if (err < 0) |
| 4539 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4540 | if (!cfg->line_outs) { |
| 4541 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4542 | spec->multiout.max_channels = 2; |
| 4543 | spec->no_analog = 1; |
| 4544 | goto dig_only; |
| 4545 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4546 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4547 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4548 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4549 | if (!spec->no_primary_hp && |
| 4550 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4551 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4552 | /* use HP as primary out */ |
| 4553 | cfg->speaker_outs = cfg->line_outs; |
| 4554 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4555 | sizeof(cfg->speaker_pins)); |
| 4556 | cfg->line_outs = cfg->hp_outs; |
| 4557 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4558 | cfg->hp_outs = 0; |
| 4559 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4560 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4561 | } |
| 4562 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4563 | err = alc_auto_fill_dac_nids(codec); |
| 4564 | if (err < 0) |
| 4565 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4566 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4567 | if (err < 0) |
| 4568 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4569 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4570 | if (err < 0) |
| 4571 | return err; |
| 4572 | err = alc_auto_create_hp_out(codec); |
| 4573 | if (err < 0) |
| 4574 | return err; |
| 4575 | err = alc_auto_create_speaker_out(codec); |
| 4576 | if (err < 0) |
| 4577 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4578 | err = alc_auto_create_shared_input(codec); |
| 4579 | if (err < 0) |
| 4580 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4581 | err = alc_auto_create_input_ctls(codec); |
| 4582 | if (err < 0) |
| 4583 | return err; |
| 4584 | |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4585 | /* check the multiple speaker pins */ |
| 4586 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4587 | spec->const_channel_count = cfg->line_outs * 2; |
| 4588 | else |
| 4589 | spec->const_channel_count = cfg->speaker_outs * 2; |
| 4590 | |
| 4591 | if (spec->multi_ios > 0) |
| 4592 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4593 | spec->const_channel_count); |
| 4594 | else |
| 4595 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4596 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4597 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4598 | alc_auto_parse_digital(codec); |
| 4599 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4600 | if (!spec->no_analog) |
| 4601 | alc_remove_invalid_adc_nids(codec); |
| 4602 | |
| 4603 | if (ssid_nids) |
| 4604 | alc_ssid_check(codec, ssid_nids); |
| 4605 | |
| 4606 | if (!spec->no_analog) { |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 4607 | err = alc_auto_check_switches(codec); |
| 4608 | if (err < 0) |
| 4609 | return err; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4610 | err = alc_auto_add_mic_boost(codec); |
| 4611 | if (err < 0) |
| 4612 | return err; |
| 4613 | } |
| 4614 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4615 | if (spec->kctls.list) |
| 4616 | add_mixer(spec, spec->kctls.list); |
| 4617 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4618 | if (!spec->no_analog && !spec->cap_mixer) |
| 4619 | set_capture_mixer(codec); |
| 4620 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4621 | return 1; |
| 4622 | } |
| 4623 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4624 | /* common preparation job for alc_spec */ |
| 4625 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4626 | { |
| 4627 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4628 | int err; |
| 4629 | |
| 4630 | if (!spec) |
| 4631 | return -ENOMEM; |
| 4632 | codec->spec = spec; |
Takashi Iwai | 1098b7c | 2012-12-17 20:03:15 +0100 | [diff] [blame] | 4633 | codec->single_adc_amp = 1; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4634 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 4635 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 4636 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 4637 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4638 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4639 | |
| 4640 | err = alc_codec_rename_from_preset(codec); |
| 4641 | if (err < 0) { |
| 4642 | kfree(spec); |
| 4643 | return err; |
| 4644 | } |
| 4645 | return 0; |
| 4646 | } |
| 4647 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4648 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4649 | { |
| 4650 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4651 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4652 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4653 | } |
| 4654 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4655 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4656 | * ALC880 fix-ups |
| 4657 | */ |
| 4658 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4659 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4660 | ALC880_FIXUP_GPIO2, |
| 4661 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4662 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4663 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4664 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4665 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4666 | ALC880_FIXUP_VOL_KNOB, |
| 4667 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4668 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4669 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4670 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4671 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4672 | ALC880_FIXUP_3ST_BASE, |
| 4673 | ALC880_FIXUP_3ST, |
| 4674 | ALC880_FIXUP_3ST_DIG, |
| 4675 | ALC880_FIXUP_5ST_BASE, |
| 4676 | ALC880_FIXUP_5ST, |
| 4677 | ALC880_FIXUP_5ST_DIG, |
| 4678 | ALC880_FIXUP_6ST_BASE, |
| 4679 | ALC880_FIXUP_6ST, |
| 4680 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4681 | }; |
| 4682 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4683 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4684 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4685 | const struct alc_fixup *fix, int action) |
| 4686 | { |
| 4687 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4688 | 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] | 4689 | } |
| 4690 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4691 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4692 | [ALC880_FIXUP_GPIO1] = { |
| 4693 | .type = ALC_FIXUP_VERBS, |
| 4694 | .v.verbs = alc_gpio1_init_verbs, |
| 4695 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4696 | [ALC880_FIXUP_GPIO2] = { |
| 4697 | .type = ALC_FIXUP_VERBS, |
| 4698 | .v.verbs = alc_gpio2_init_verbs, |
| 4699 | }, |
| 4700 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4701 | .type = ALC_FIXUP_VERBS, |
| 4702 | .v.verbs = (const struct hda_verb[]) { |
| 4703 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4704 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4705 | { } |
| 4706 | }, |
| 4707 | .chained = true, |
| 4708 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4709 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4710 | [ALC880_FIXUP_LG] = { |
| 4711 | .type = ALC_FIXUP_PINS, |
| 4712 | .v.pins = (const struct alc_pincfg[]) { |
| 4713 | /* disable bogus unused pins */ |
| 4714 | { 0x16, 0x411111f0 }, |
| 4715 | { 0x18, 0x411111f0 }, |
| 4716 | { 0x1a, 0x411111f0 }, |
| 4717 | { } |
| 4718 | } |
| 4719 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4720 | [ALC880_FIXUP_W810] = { |
| 4721 | .type = ALC_FIXUP_PINS, |
| 4722 | .v.pins = (const struct alc_pincfg[]) { |
| 4723 | /* disable bogus unused pins */ |
| 4724 | { 0x17, 0x411111f0 }, |
| 4725 | { } |
| 4726 | }, |
| 4727 | .chained = true, |
| 4728 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4729 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4730 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4731 | .type = ALC_FIXUP_VERBS, |
| 4732 | .v.verbs = (const struct hda_verb[]) { |
| 4733 | /* change to EAPD mode */ |
| 4734 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4735 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4736 | {} |
| 4737 | }, |
| 4738 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4739 | [ALC880_FIXUP_TCL_S700] = { |
| 4740 | .type = ALC_FIXUP_VERBS, |
| 4741 | .v.verbs = (const struct hda_verb[]) { |
| 4742 | /* change to EAPD mode */ |
| 4743 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4744 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4745 | {} |
| 4746 | }, |
| 4747 | .chained = true, |
| 4748 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4749 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4750 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4751 | .type = ALC_FIXUP_FUNC, |
| 4752 | .v.func = alc880_fixup_vol_knob, |
| 4753 | }, |
| 4754 | [ALC880_FIXUP_FUJITSU] = { |
| 4755 | /* override all pins as BIOS on old Amilo is broken */ |
| 4756 | .type = ALC_FIXUP_PINS, |
| 4757 | .v.pins = (const struct alc_pincfg[]) { |
| 4758 | { 0x14, 0x0121411f }, /* HP */ |
| 4759 | { 0x15, 0x99030120 }, /* speaker */ |
| 4760 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4761 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4762 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4763 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4764 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4765 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4766 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4767 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4768 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4769 | { } |
| 4770 | }, |
| 4771 | .chained = true, |
| 4772 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4773 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4774 | [ALC880_FIXUP_F1734] = { |
| 4775 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4776 | .type = ALC_FIXUP_PINS, |
| 4777 | .v.pins = (const struct alc_pincfg[]) { |
| 4778 | { 0x14, 0x0121411f }, /* HP */ |
| 4779 | { 0x15, 0x99030120 }, /* speaker */ |
| 4780 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4781 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4782 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4783 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4784 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4785 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4786 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4787 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4788 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4789 | { } |
| 4790 | }, |
| 4791 | .chained = true, |
| 4792 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4793 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4794 | [ALC880_FIXUP_UNIWILL] = { |
| 4795 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4796 | .type = ALC_FIXUP_PINS, |
| 4797 | .v.pins = (const struct alc_pincfg[]) { |
| 4798 | { 0x14, 0x0121411f }, /* HP */ |
| 4799 | { 0x15, 0x99030120 }, /* speaker */ |
| 4800 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4801 | { } |
| 4802 | }, |
| 4803 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4804 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4805 | .type = ALC_FIXUP_PINS, |
| 4806 | .v.pins = (const struct alc_pincfg[]) { |
| 4807 | /* disable bogus unused pins */ |
| 4808 | { 0x17, 0x411111f0 }, |
| 4809 | { 0x19, 0x411111f0 }, |
| 4810 | { 0x1b, 0x411111f0 }, |
| 4811 | { 0x1f, 0x411111f0 }, |
| 4812 | { } |
| 4813 | } |
| 4814 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4815 | [ALC880_FIXUP_Z71V] = { |
| 4816 | .type = ALC_FIXUP_PINS, |
| 4817 | .v.pins = (const struct alc_pincfg[]) { |
| 4818 | /* set up the whole pins as BIOS is utterly broken */ |
| 4819 | { 0x14, 0x99030120 }, /* speaker */ |
| 4820 | { 0x15, 0x0121411f }, /* HP */ |
| 4821 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4822 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4823 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4824 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4825 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4826 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4827 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4828 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4829 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4830 | { } |
| 4831 | } |
| 4832 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4833 | [ALC880_FIXUP_3ST_BASE] = { |
| 4834 | .type = ALC_FIXUP_PINS, |
| 4835 | .v.pins = (const struct alc_pincfg[]) { |
| 4836 | { 0x14, 0x01014010 }, /* line-out */ |
| 4837 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4838 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4839 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4840 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4841 | { 0x19, 0x0121411f }, /* HP */ |
| 4842 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4843 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4844 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4845 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4846 | /* 0x1e is filled in below */ |
| 4847 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4848 | { } |
| 4849 | } |
| 4850 | }, |
| 4851 | [ALC880_FIXUP_3ST] = { |
| 4852 | .type = ALC_FIXUP_PINS, |
| 4853 | .v.pins = (const struct alc_pincfg[]) { |
| 4854 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4855 | { } |
| 4856 | }, |
| 4857 | .chained = true, |
| 4858 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4859 | }, |
| 4860 | [ALC880_FIXUP_3ST_DIG] = { |
| 4861 | .type = ALC_FIXUP_PINS, |
| 4862 | .v.pins = (const struct alc_pincfg[]) { |
| 4863 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4864 | { } |
| 4865 | }, |
| 4866 | .chained = true, |
| 4867 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4868 | }, |
| 4869 | [ALC880_FIXUP_5ST_BASE] = { |
| 4870 | .type = ALC_FIXUP_PINS, |
| 4871 | .v.pins = (const struct alc_pincfg[]) { |
| 4872 | { 0x14, 0x01014010 }, /* front */ |
| 4873 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4874 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4875 | { 0x17, 0x01016412 }, /* surr */ |
| 4876 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4877 | { 0x19, 0x0121411f }, /* HP */ |
| 4878 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4879 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4880 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4881 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4882 | /* 0x1e is filled in below */ |
| 4883 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4884 | { } |
| 4885 | } |
| 4886 | }, |
| 4887 | [ALC880_FIXUP_5ST] = { |
| 4888 | .type = ALC_FIXUP_PINS, |
| 4889 | .v.pins = (const struct alc_pincfg[]) { |
| 4890 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4891 | { } |
| 4892 | }, |
| 4893 | .chained = true, |
| 4894 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4895 | }, |
| 4896 | [ALC880_FIXUP_5ST_DIG] = { |
| 4897 | .type = ALC_FIXUP_PINS, |
| 4898 | .v.pins = (const struct alc_pincfg[]) { |
| 4899 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4900 | { } |
| 4901 | }, |
| 4902 | .chained = true, |
| 4903 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4904 | }, |
| 4905 | [ALC880_FIXUP_6ST_BASE] = { |
| 4906 | .type = ALC_FIXUP_PINS, |
| 4907 | .v.pins = (const struct alc_pincfg[]) { |
| 4908 | { 0x14, 0x01014010 }, /* front */ |
| 4909 | { 0x15, 0x01016412 }, /* surr */ |
| 4910 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4911 | { 0x17, 0x01012414 }, /* side */ |
| 4912 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4913 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4914 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4915 | { 0x1b, 0x0121411f }, /* HP */ |
| 4916 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4917 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4918 | /* 0x1e is filled in below */ |
| 4919 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4920 | { } |
| 4921 | } |
| 4922 | }, |
| 4923 | [ALC880_FIXUP_6ST] = { |
| 4924 | .type = ALC_FIXUP_PINS, |
| 4925 | .v.pins = (const struct alc_pincfg[]) { |
| 4926 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4927 | { } |
| 4928 | }, |
| 4929 | .chained = true, |
| 4930 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4931 | }, |
| 4932 | [ALC880_FIXUP_6ST_DIG] = { |
| 4933 | .type = ALC_FIXUP_PINS, |
| 4934 | .v.pins = (const struct alc_pincfg[]) { |
| 4935 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4936 | { } |
| 4937 | }, |
| 4938 | .chained = true, |
| 4939 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4940 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4941 | }; |
| 4942 | |
| 4943 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4944 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4945 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4946 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4947 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4948 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4949 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4950 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4951 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4952 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4953 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4954 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4955 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4956 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4957 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4958 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4959 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4960 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4961 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4962 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4963 | |
| 4964 | /* Below is the copied entries from alc880_quirks.c. |
| 4965 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4966 | * on these machines, thus they are kept to be compatible with |
| 4967 | * the old static quirks. Once when it's confirmed to work without |
| 4968 | * these overrides, it'd be better to remove. |
| 4969 | */ |
| 4970 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4971 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4972 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4973 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4974 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4975 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4976 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4977 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4978 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4979 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4980 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4981 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4982 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4983 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4984 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4985 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4986 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4987 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4988 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4989 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4990 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4991 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4992 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4993 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4994 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4995 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4996 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4997 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4998 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4999 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 5000 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5001 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5002 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 5003 | /* default Intel */ |
| 5004 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 5005 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 5006 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 5007 | {} |
| 5008 | }; |
| 5009 | |
| 5010 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 5011 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 5012 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 5013 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 5014 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 5015 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 5016 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 5017 | {} |
| 5018 | }; |
| 5019 | |
| 5020 | |
| 5021 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5022 | * OK, here we have finally the patch for ALC880 |
| 5023 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5024 | static int patch_alc880(struct hda_codec *codec) |
| 5025 | { |
| 5026 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5027 | int err; |
| 5028 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5029 | err = alc_alloc_spec(codec, 0x0b); |
| 5030 | if (err < 0) |
| 5031 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5032 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5033 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 5034 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5035 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 5036 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 5037 | alc880_fixups); |
| 5038 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5039 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 5040 | /* automatic parse from the BIOS config */ |
| 5041 | err = alc880_parse_auto_config(codec); |
| 5042 | if (err < 0) |
| 5043 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5044 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5045 | if (!spec->no_analog) { |
| 5046 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5047 | if (err < 0) |
| 5048 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5049 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 5050 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5051 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5052 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5053 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 5054 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5055 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5056 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5057 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5058 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5059 | |
| 5060 | error: |
| 5061 | alc_free(codec); |
| 5062 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5063 | } |
| 5064 | |
| 5065 | |
| 5066 | /* |
| 5067 | * ALC260 support |
| 5068 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5069 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 5070 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5071 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5072 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 5073 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5074 | } |
| 5075 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5076 | /* |
| 5077 | * Pin config fixes |
| 5078 | */ |
| 5079 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5080 | ALC260_FIXUP_HP_DC5750, |
| 5081 | ALC260_FIXUP_HP_PIN_0F, |
| 5082 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5083 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5084 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 5085 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5086 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5087 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5088 | }; |
| 5089 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5090 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 5091 | { |
| 5092 | struct alc_spec *spec = codec->spec; |
| 5093 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 5094 | spec->hp_jack_present); |
| 5095 | } |
| 5096 | |
| 5097 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 5098 | const struct alc_fixup *fix, int action) |
| 5099 | { |
| 5100 | struct alc_spec *spec = codec->spec; |
| 5101 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 5102 | /* although the machine has only one output pin, we need to |
| 5103 | * toggle GPIO1 according to the jack state |
| 5104 | */ |
| 5105 | spec->automute_hook = alc260_gpio1_automute; |
| 5106 | spec->detect_hp = 1; |
| 5107 | spec->automute_speaker = 1; |
| 5108 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5109 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 5110 | alc_hp_automute); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5111 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5112 | } |
| 5113 | } |
| 5114 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5115 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 5116 | const struct alc_fixup *fix, int action) |
| 5117 | { |
| 5118 | struct alc_spec *spec = codec->spec; |
| 5119 | static const struct alc_pincfg pincfgs[] = { |
| 5120 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 5121 | { 0x12, 0x90a60160 }, /* int mic */ |
| 5122 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 5123 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 5124 | /* disable bogus I/O pins */ |
| 5125 | { 0x10, 0x411111f0 }, |
| 5126 | { 0x11, 0x411111f0 }, |
| 5127 | { 0x14, 0x411111f0 }, |
| 5128 | { 0x15, 0x411111f0 }, |
| 5129 | { 0x16, 0x411111f0 }, |
| 5130 | { 0x17, 0x411111f0 }, |
| 5131 | { 0x19, 0x411111f0 }, |
| 5132 | { } |
| 5133 | }; |
| 5134 | |
| 5135 | switch (action) { |
| 5136 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 5137 | alc_apply_pincfgs(codec, pincfgs); |
| 5138 | break; |
| 5139 | case ALC_FIXUP_ACT_PROBE: |
| 5140 | spec->init_amp = ALC_INIT_NONE; |
| 5141 | break; |
| 5142 | } |
| 5143 | } |
| 5144 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5145 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5146 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5147 | .type = ALC_FIXUP_PINS, |
| 5148 | .v.pins = (const struct alc_pincfg[]) { |
| 5149 | { 0x11, 0x90130110 }, /* speaker */ |
| 5150 | { } |
| 5151 | } |
| 5152 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5153 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 5154 | .type = ALC_FIXUP_PINS, |
| 5155 | .v.pins = (const struct alc_pincfg[]) { |
| 5156 | { 0x0f, 0x01214000 }, /* HP */ |
| 5157 | { } |
| 5158 | } |
| 5159 | }, |
| 5160 | [ALC260_FIXUP_COEF] = { |
| 5161 | .type = ALC_FIXUP_VERBS, |
| 5162 | .v.verbs = (const struct hda_verb[]) { |
| 5163 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5164 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 5165 | { } |
| 5166 | }, |
| 5167 | .chained = true, |
| 5168 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5169 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5170 | [ALC260_FIXUP_GPIO1] = { |
| 5171 | .type = ALC_FIXUP_VERBS, |
| 5172 | .v.verbs = alc_gpio1_init_verbs, |
| 5173 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5174 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 5175 | .type = ALC_FIXUP_FUNC, |
| 5176 | .v.func = alc260_fixup_gpio1_toggle, |
| 5177 | .chained = true, |
| 5178 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5179 | }, |
| 5180 | [ALC260_FIXUP_REPLACER] = { |
| 5181 | .type = ALC_FIXUP_VERBS, |
| 5182 | .v.verbs = (const struct hda_verb[]) { |
| 5183 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5184 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5185 | { } |
| 5186 | }, |
| 5187 | .chained = true, |
| 5188 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 5189 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5190 | [ALC260_FIXUP_HP_B1900] = { |
| 5191 | .type = ALC_FIXUP_FUNC, |
| 5192 | .v.func = alc260_fixup_gpio1_toggle, |
| 5193 | .chained = true, |
| 5194 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5195 | }, |
| 5196 | [ALC260_FIXUP_KN1] = { |
| 5197 | .type = ALC_FIXUP_FUNC, |
| 5198 | .v.func = alc260_fixup_kn1, |
| 5199 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5200 | }; |
| 5201 | |
| 5202 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5203 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5204 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5205 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5206 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5207 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 5208 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5209 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5210 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5211 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5212 | {} |
| 5213 | }; |
| 5214 | |
| 5215 | /* |
| 5216 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5217 | static int patch_alc260(struct hda_codec *codec) |
| 5218 | { |
| 5219 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5220 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5221 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5222 | err = alc_alloc_spec(codec, 0x07); |
| 5223 | if (err < 0) |
| 5224 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5225 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5226 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5227 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5228 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5229 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5230 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5231 | /* automatic parse from the BIOS config */ |
| 5232 | err = alc260_parse_auto_config(codec); |
| 5233 | if (err < 0) |
| 5234 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5235 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5236 | if (!spec->no_analog) { |
| 5237 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5238 | if (err < 0) |
| 5239 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5240 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5241 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5242 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5243 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5244 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5245 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5246 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5247 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5248 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5249 | |
| 5250 | error: |
| 5251 | alc_free(codec); |
| 5252 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5253 | } |
| 5254 | |
| 5255 | |
| 5256 | /* |
| 5257 | * ALC882/883/885/888/889 support |
| 5258 | * |
| 5259 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5260 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5261 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5262 | * 6-channel independent captures. |
| 5263 | * |
| 5264 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5265 | * driver yet). |
| 5266 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5267 | |
| 5268 | /* |
| 5269 | * Pin config fixes |
| 5270 | */ |
| 5271 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5272 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5273 | ALC882_FIXUP_LENOVO_Y530, |
| 5274 | ALC882_FIXUP_PB_M5210, |
| 5275 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5276 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5277 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5278 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5279 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5280 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5281 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5282 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5283 | ALC882_FIXUP_GPIO1, |
| 5284 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5285 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5286 | ALC889_FIXUP_COEF, |
| 5287 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5288 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5289 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5290 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5291 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5292 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5293 | ALC889_FIXUP_MBP_VREF, |
| 5294 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5295 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5296 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5297 | }; |
| 5298 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5299 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5300 | const struct alc_fixup *fix, int action) |
| 5301 | { |
| 5302 | if (action != ALC_FIXUP_ACT_INIT) |
| 5303 | return; |
| 5304 | alc889_coef_init(codec); |
| 5305 | } |
| 5306 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5307 | /* toggle speaker-output according to the hp-jack state */ |
| 5308 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5309 | { |
| 5310 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5311 | |
| 5312 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5313 | AC_VERB_GET_GPIO_DATA, 0); |
| 5314 | |
| 5315 | if (!muted) |
| 5316 | gpiostate |= (1 << pin); |
| 5317 | else |
| 5318 | gpiostate &= ~(1 << pin); |
| 5319 | |
| 5320 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5321 | AC_VERB_GET_GPIO_MASK, 0); |
| 5322 | gpiomask |= (1 << pin); |
| 5323 | |
| 5324 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5325 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5326 | gpiodir |= (1 << pin); |
| 5327 | |
| 5328 | |
| 5329 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5330 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5331 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5332 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5333 | |
| 5334 | msleep(1); |
| 5335 | |
| 5336 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5337 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5338 | } |
| 5339 | |
| 5340 | /* set up GPIO at initialization */ |
| 5341 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5342 | const struct alc_fixup *fix, int action) |
| 5343 | { |
| 5344 | if (action != ALC_FIXUP_ACT_INIT) |
| 5345 | return; |
| 5346 | alc882_gpio_mute(codec, 0, 0); |
| 5347 | alc882_gpio_mute(codec, 1, 0); |
| 5348 | } |
| 5349 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5350 | /* Fix the connection of some pins for ALC889: |
| 5351 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5352 | * work correctly (bko#42740) |
| 5353 | */ |
| 5354 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5355 | const struct alc_fixup *fix, int action) |
| 5356 | { |
| 5357 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5358 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5359 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5360 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5361 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5362 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5363 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5364 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5365 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5366 | /* restore the connections */ |
| 5367 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5368 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5369 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5370 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5371 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5372 | } |
| 5373 | } |
| 5374 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5375 | /* Set VREF on HP pin */ |
| 5376 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5377 | const struct alc_fixup *fix, int action) |
| 5378 | { |
| 5379 | struct alc_spec *spec = codec->spec; |
| 5380 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5381 | int i; |
| 5382 | |
| 5383 | if (action != ALC_FIXUP_ACT_INIT) |
| 5384 | return; |
| 5385 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5386 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5387 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5388 | continue; |
| 5389 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5390 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5391 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5392 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5393 | spec->keep_vref_in_automute = 1; |
| 5394 | break; |
| 5395 | } |
| 5396 | } |
| 5397 | |
| 5398 | /* Set VREF on speaker pins on imac91 */ |
| 5399 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5400 | const struct alc_fixup *fix, int action) |
| 5401 | { |
| 5402 | struct alc_spec *spec = codec->spec; |
| 5403 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5404 | int i; |
| 5405 | |
| 5406 | if (action != ALC_FIXUP_ACT_INIT) |
| 5407 | return; |
| 5408 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5409 | unsigned int val; |
| 5410 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5411 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5412 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5413 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5414 | } |
| 5415 | spec->keep_vref_in_automute = 1; |
| 5416 | } |
| 5417 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5418 | /* Don't take HP output as primary |
| 5419 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5420 | */ |
| 5421 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5422 | const struct alc_fixup *fix, int action) |
| 5423 | { |
| 5424 | struct alc_spec *spec = codec->spec; |
| 5425 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5426 | spec->no_primary_hp = 1; |
| 5427 | } |
| 5428 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5429 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5430 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5431 | .type = ALC_FIXUP_PINS, |
| 5432 | .v.pins = (const struct alc_pincfg[]) { |
| 5433 | { 0x15, 0x01080104 }, /* side */ |
| 5434 | { 0x16, 0x01011012 }, /* rear */ |
| 5435 | { 0x17, 0x01016011 }, /* clfe */ |
| 5436 | { } |
| 5437 | } |
| 5438 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5439 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5440 | .type = ALC_FIXUP_PINS, |
| 5441 | .v.pins = (const struct alc_pincfg[]) { |
| 5442 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5443 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5444 | { } |
| 5445 | } |
| 5446 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5447 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5448 | .type = ALC_FIXUP_VERBS, |
| 5449 | .v.verbs = (const struct hda_verb[]) { |
| 5450 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5451 | {} |
| 5452 | } |
| 5453 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5454 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5455 | .type = ALC_FIXUP_FUNC, |
| 5456 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5457 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5458 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5459 | .type = ALC_FIXUP_PINS, |
| 5460 | .v.pins = (const struct alc_pincfg[]) { |
| 5461 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5462 | { } |
| 5463 | } |
| 5464 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5465 | [ALC889_FIXUP_CD] = { |
| 5466 | .type = ALC_FIXUP_PINS, |
| 5467 | .v.pins = (const struct alc_pincfg[]) { |
| 5468 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5469 | { } |
| 5470 | } |
| 5471 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5472 | [ALC889_FIXUP_VAIO_TT] = { |
| 5473 | .type = ALC_FIXUP_PINS, |
| 5474 | .v.pins = (const struct alc_pincfg[]) { |
| 5475 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5476 | { } |
| 5477 | } |
| 5478 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5479 | [ALC888_FIXUP_EEE1601] = { |
| 5480 | .type = ALC_FIXUP_VERBS, |
| 5481 | .v.verbs = (const struct hda_verb[]) { |
| 5482 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5483 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5484 | { } |
| 5485 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5486 | }, |
| 5487 | [ALC882_FIXUP_EAPD] = { |
| 5488 | .type = ALC_FIXUP_VERBS, |
| 5489 | .v.verbs = (const struct hda_verb[]) { |
| 5490 | /* change to EAPD mode */ |
| 5491 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5492 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5493 | { } |
| 5494 | } |
| 5495 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5496 | [ALC883_FIXUP_EAPD] = { |
| 5497 | .type = ALC_FIXUP_VERBS, |
| 5498 | .v.verbs = (const struct hda_verb[]) { |
| 5499 | /* change to EAPD mode */ |
| 5500 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5501 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5502 | { } |
| 5503 | } |
| 5504 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5505 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5506 | .type = ALC_FIXUP_VERBS, |
| 5507 | .v.verbs = (const struct hda_verb[]) { |
| 5508 | /* eanable EAPD on Acer laptops */ |
| 5509 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5510 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5511 | { } |
| 5512 | } |
| 5513 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5514 | [ALC882_FIXUP_GPIO1] = { |
| 5515 | .type = ALC_FIXUP_VERBS, |
| 5516 | .v.verbs = alc_gpio1_init_verbs, |
| 5517 | }, |
| 5518 | [ALC882_FIXUP_GPIO2] = { |
| 5519 | .type = ALC_FIXUP_VERBS, |
| 5520 | .v.verbs = alc_gpio2_init_verbs, |
| 5521 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5522 | [ALC882_FIXUP_GPIO3] = { |
| 5523 | .type = ALC_FIXUP_VERBS, |
| 5524 | .v.verbs = alc_gpio3_init_verbs, |
| 5525 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5526 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5527 | .type = ALC_FIXUP_VERBS, |
| 5528 | .v.verbs = alc_gpio1_init_verbs, |
| 5529 | .chained = true, |
| 5530 | .chain_id = ALC882_FIXUP_EAPD, |
| 5531 | }, |
| 5532 | [ALC889_FIXUP_COEF] = { |
| 5533 | .type = ALC_FIXUP_FUNC, |
| 5534 | .v.func = alc889_fixup_coef, |
| 5535 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5536 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5537 | .type = ALC_FIXUP_PINS, |
| 5538 | .v.pins = (const struct alc_pincfg[]) { |
| 5539 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5540 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5541 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5542 | }, |
| 5543 | .chained = true, |
| 5544 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5545 | }, |
| 5546 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5547 | .type = ALC_FIXUP_PINS, |
| 5548 | .v.pins = (const struct alc_pincfg[]) { |
| 5549 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5550 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5551 | { } |
| 5552 | }, |
| 5553 | .chained = true, |
| 5554 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5555 | }, |
| 5556 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5557 | /* additional init verbs for Acer Aspire 8930G */ |
| 5558 | .type = ALC_FIXUP_VERBS, |
| 5559 | .v.verbs = (const struct hda_verb[]) { |
| 5560 | /* Enable all DACs */ |
| 5561 | /* DAC DISABLE/MUTE 1? */ |
| 5562 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5563 | * apparently. Init=0x38 */ |
| 5564 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5565 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5566 | /* DAC DISABLE/MUTE 2? */ |
| 5567 | /* some bit here disables the other DACs. |
| 5568 | * Init=0x4900 */ |
| 5569 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5570 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5571 | /* DMIC fix |
| 5572 | * This laptop has a stereo digital microphone. |
| 5573 | * The mics are only 1cm apart which makes the stereo |
| 5574 | * useless. However, either the mic or the ALC889 |
| 5575 | * makes the signal become a difference/sum signal |
| 5576 | * instead of standard stereo, which is annoying. |
| 5577 | * So instead we flip this bit which makes the |
| 5578 | * codec replicate the sum signal to both channels, |
| 5579 | * turning it into a normal mono mic. |
| 5580 | */ |
| 5581 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5582 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5583 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5584 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5585 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5586 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5587 | }, |
| 5588 | .chained = true, |
| 5589 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5590 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5591 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5592 | .type = ALC_FIXUP_FUNC, |
| 5593 | .v.func = alc885_fixup_macpro_gpio, |
| 5594 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5595 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5596 | .type = ALC_FIXUP_FUNC, |
| 5597 | .v.func = alc889_fixup_dac_route, |
| 5598 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5599 | [ALC889_FIXUP_MBP_VREF] = { |
| 5600 | .type = ALC_FIXUP_FUNC, |
| 5601 | .v.func = alc889_fixup_mbp_vref, |
| 5602 | .chained = true, |
| 5603 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5604 | }, |
| 5605 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5606 | .type = ALC_FIXUP_FUNC, |
| 5607 | .v.func = alc889_fixup_imac91_vref, |
| 5608 | .chained = true, |
| 5609 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5610 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5611 | [ALC882_FIXUP_INV_DMIC] = { |
| 5612 | .type = ALC_FIXUP_FUNC, |
| 5613 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5614 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5615 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5616 | .type = ALC_FIXUP_FUNC, |
| 5617 | .v.func = alc882_fixup_no_primary_hp, |
| 5618 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5619 | }; |
| 5620 | |
| 5621 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5622 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5623 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5624 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5625 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5626 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5627 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5628 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5629 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5630 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5631 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5632 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5633 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5634 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5635 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5636 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5637 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5638 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5639 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5640 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5641 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5642 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5643 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5644 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5645 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5646 | 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] | 5647 | 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] | 5648 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5649 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5650 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5651 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5652 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5653 | 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] | 5654 | |
| 5655 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5656 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5657 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5658 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5659 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5660 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5661 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5662 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5663 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5664 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5665 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5666 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5667 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5668 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5669 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5670 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5671 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5672 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5673 | 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] | 5674 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5675 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5676 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5677 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5678 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5679 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5680 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5681 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5682 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5683 | 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] | 5684 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5685 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5686 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5687 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5688 | {} |
| 5689 | }; |
| 5690 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5691 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5692 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5693 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5694 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5695 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5696 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5697 | {} |
| 5698 | }; |
| 5699 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5700 | /* |
| 5701 | * BIOS auto configuration |
| 5702 | */ |
| 5703 | /* almost identical with ALC880 parser... */ |
| 5704 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5705 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5706 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5707 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5708 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5709 | } |
| 5710 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5711 | /* |
| 5712 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5713 | static int patch_alc882(struct hda_codec *codec) |
| 5714 | { |
| 5715 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5716 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5717 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5718 | err = alc_alloc_spec(codec, 0x0b); |
| 5719 | if (err < 0) |
| 5720 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5721 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5722 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5723 | |
| 5724 | switch (codec->vendor_id) { |
| 5725 | case 0x10ec0882: |
| 5726 | case 0x10ec0885: |
| 5727 | break; |
| 5728 | default: |
| 5729 | /* ALC883 and variants */ |
| 5730 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5731 | break; |
| 5732 | } |
| 5733 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5734 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5735 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5736 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5737 | |
| 5738 | alc_auto_parse_customize_define(codec); |
| 5739 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5740 | /* automatic parse from the BIOS config */ |
| 5741 | err = alc882_parse_auto_config(codec); |
| 5742 | if (err < 0) |
| 5743 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5744 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5745 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5746 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5747 | if (err < 0) |
| 5748 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5749 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5750 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5751 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5752 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5753 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5754 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5755 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5756 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5757 | |
| 5758 | error: |
| 5759 | alc_free(codec); |
| 5760 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5761 | } |
| 5762 | |
| 5763 | |
| 5764 | /* |
| 5765 | * ALC262 support |
| 5766 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5767 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5768 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5769 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5770 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5771 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5772 | } |
| 5773 | |
| 5774 | /* |
| 5775 | * Pin config fixes |
| 5776 | */ |
| 5777 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5778 | ALC262_FIXUP_FSC_H270, |
| 5779 | ALC262_FIXUP_HP_Z200, |
| 5780 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5781 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5782 | ALC262_FIXUP_BENQ, |
| 5783 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5784 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5785 | }; |
| 5786 | |
| 5787 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5788 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5789 | .type = ALC_FIXUP_PINS, |
| 5790 | .v.pins = (const struct alc_pincfg[]) { |
| 5791 | { 0x14, 0x99130110 }, /* speaker */ |
| 5792 | { 0x15, 0x0221142f }, /* front HP */ |
| 5793 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5794 | { } |
| 5795 | } |
| 5796 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5797 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5798 | .type = ALC_FIXUP_PINS, |
| 5799 | .v.pins = (const struct alc_pincfg[]) { |
| 5800 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5801 | { } |
| 5802 | } |
| 5803 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5804 | [ALC262_FIXUP_TYAN] = { |
| 5805 | .type = ALC_FIXUP_PINS, |
| 5806 | .v.pins = (const struct alc_pincfg[]) { |
| 5807 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5808 | { } |
| 5809 | } |
| 5810 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5811 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5812 | .type = ALC_FIXUP_VERBS, |
| 5813 | .v.verbs = (const struct hda_verb[]) { |
| 5814 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5815 | {} |
| 5816 | }, |
| 5817 | .chained = true, |
| 5818 | .chain_id = ALC262_FIXUP_BENQ, |
| 5819 | }, |
| 5820 | [ALC262_FIXUP_BENQ] = { |
| 5821 | .type = ALC_FIXUP_VERBS, |
| 5822 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5823 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5824 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5825 | {} |
| 5826 | } |
| 5827 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5828 | [ALC262_FIXUP_BENQ_T31] = { |
| 5829 | .type = ALC_FIXUP_VERBS, |
| 5830 | .v.verbs = (const struct hda_verb[]) { |
| 5831 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5832 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5833 | {} |
| 5834 | } |
| 5835 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5836 | [ALC262_FIXUP_INV_DMIC] = { |
| 5837 | .type = ALC_FIXUP_FUNC, |
| 5838 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5839 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5840 | }; |
| 5841 | |
| 5842 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5843 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5844 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5845 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5846 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5847 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5848 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5849 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5850 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5851 | {} |
| 5852 | }; |
| 5853 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5854 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5855 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5856 | {} |
| 5857 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5858 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5859 | /* |
| 5860 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5861 | static int patch_alc262(struct hda_codec *codec) |
| 5862 | { |
| 5863 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5864 | int err; |
| 5865 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5866 | err = alc_alloc_spec(codec, 0x0b); |
| 5867 | if (err < 0) |
| 5868 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5869 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5870 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5871 | |
| 5872 | #if 0 |
| 5873 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5874 | * under-run |
| 5875 | */ |
| 5876 | { |
| 5877 | int tmp; |
| 5878 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5879 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5880 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5881 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5882 | } |
| 5883 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5884 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5885 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5886 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5887 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5888 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5889 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5890 | alc_auto_parse_customize_define(codec); |
| 5891 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5892 | /* automatic parse from the BIOS config */ |
| 5893 | err = alc262_parse_auto_config(codec); |
| 5894 | if (err < 0) |
| 5895 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5896 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5897 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5898 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5899 | if (err < 0) |
| 5900 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5901 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5902 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5903 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5904 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5905 | spec->shutup = alc_eapd_shutup; |
| 5906 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5907 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5908 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5909 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5910 | |
| 5911 | error: |
| 5912 | alc_free(codec); |
| 5913 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5914 | } |
| 5915 | |
| 5916 | /* |
| 5917 | * ALC268 |
| 5918 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5919 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5920 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5921 | .ops = &snd_hda_bind_sw, |
| 5922 | .values = { |
| 5923 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5924 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5925 | 0 |
| 5926 | }, |
| 5927 | }; |
| 5928 | |
| 5929 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5930 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5931 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5932 | { } |
| 5933 | }; |
| 5934 | |
| 5935 | /* set PCBEEP vol = 0, mute connections */ |
| 5936 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5937 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5938 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5939 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5940 | { } |
| 5941 | }; |
| 5942 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5943 | enum { |
| 5944 | ALC268_FIXUP_INV_DMIC, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5945 | ALC268_FIXUP_HP_EAPD, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5946 | }; |
| 5947 | |
| 5948 | static const struct alc_fixup alc268_fixups[] = { |
| 5949 | [ALC268_FIXUP_INV_DMIC] = { |
| 5950 | .type = ALC_FIXUP_FUNC, |
| 5951 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5952 | }, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5953 | [ALC268_FIXUP_HP_EAPD] = { |
| 5954 | .type = ALC_FIXUP_VERBS, |
| 5955 | .v.verbs = (const struct hda_verb[]) { |
| 5956 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5957 | {} |
| 5958 | } |
| 5959 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5960 | }; |
| 5961 | |
| 5962 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 5963 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5964 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
| 5965 | {} |
| 5966 | }; |
| 5967 | |
| 5968 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 5969 | /* below is codec SSID since multiple Toshiba laptops have the |
| 5970 | * same PCI SSID 1179:ff00 |
| 5971 | */ |
| 5972 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5973 | {} |
| 5974 | }; |
| 5975 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5976 | /* |
| 5977 | * BIOS auto configuration |
| 5978 | */ |
| 5979 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5980 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5981 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5982 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5983 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5984 | if (err > 0) { |
| 5985 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5986 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5987 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5988 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5989 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5990 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5991 | } |
| 5992 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5993 | /* |
| 5994 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5995 | static int patch_alc268(struct hda_codec *codec) |
| 5996 | { |
| 5997 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5998 | int i, has_beep, err; |
| 5999 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6000 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6001 | err = alc_alloc_spec(codec, 0); |
| 6002 | if (err < 0) |
| 6003 | return err; |
| 6004 | |
| 6005 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6006 | |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 6007 | alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6008 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6009 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 6010 | /* automatic parse from the BIOS config */ |
| 6011 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6012 | if (err < 0) |
| 6013 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6014 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6015 | has_beep = 0; |
| 6016 | for (i = 0; i < spec->num_mixers; i++) { |
| 6017 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 6018 | has_beep = 1; |
| 6019 | break; |
| 6020 | } |
| 6021 | } |
| 6022 | |
| 6023 | if (has_beep) { |
| 6024 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6025 | if (err < 0) |
| 6026 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6027 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 6028 | /* override the amp caps for beep generator */ |
| 6029 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 6030 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 6031 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6032 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6033 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 6034 | } |
| 6035 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6036 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6037 | spec->shutup = alc_eapd_shutup; |
| 6038 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6039 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6040 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6041 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6042 | |
| 6043 | error: |
| 6044 | alc_free(codec); |
| 6045 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6046 | } |
| 6047 | |
| 6048 | /* |
| 6049 | * ALC269 |
| 6050 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6051 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 6052 | .substreams = 1, |
| 6053 | .channels_min = 2, |
| 6054 | .channels_max = 8, |
| 6055 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 6056 | /* NID is set in alc_build_pcms */ |
| 6057 | .ops = { |
| 6058 | .open = alc_playback_pcm_open, |
| 6059 | .prepare = alc_playback_pcm_prepare, |
| 6060 | .cleanup = alc_playback_pcm_cleanup |
| 6061 | }, |
| 6062 | }; |
| 6063 | |
| 6064 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 6065 | .substreams = 1, |
| 6066 | .channels_min = 2, |
| 6067 | .channels_max = 2, |
| 6068 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 6069 | /* NID is set in alc_build_pcms */ |
| 6070 | }; |
| 6071 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6072 | /* different alc269-variants */ |
| 6073 | enum { |
| 6074 | ALC269_TYPE_ALC269VA, |
| 6075 | ALC269_TYPE_ALC269VB, |
| 6076 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6077 | ALC269_TYPE_ALC269VD, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6078 | ALC269_TYPE_ALC280, |
| 6079 | ALC269_TYPE_ALC282, |
| 6080 | ALC269_TYPE_ALC284, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6081 | }; |
| 6082 | |
| 6083 | /* |
| 6084 | * BIOS auto configuration |
| 6085 | */ |
| 6086 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 6087 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6088 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6089 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 6090 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6091 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6092 | const hda_nid_t *ssids; |
| 6093 | |
| 6094 | switch (spec->codec_variant) { |
| 6095 | case ALC269_TYPE_ALC269VA: |
| 6096 | case ALC269_TYPE_ALC269VC: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6097 | case ALC269_TYPE_ALC280: |
| 6098 | case ALC269_TYPE_ALC284: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6099 | ssids = alc269va_ssids; |
| 6100 | break; |
| 6101 | case ALC269_TYPE_ALC269VB: |
| 6102 | case ALC269_TYPE_ALC269VD: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6103 | case ALC269_TYPE_ALC282: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6104 | ssids = alc269_ssids; |
| 6105 | break; |
| 6106 | default: |
| 6107 | ssids = alc269_ssids; |
| 6108 | break; |
| 6109 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6110 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6111 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6112 | } |
| 6113 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6114 | 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] | 6115 | { |
| 6116 | int val = alc_read_coef_idx(codec, 0x04); |
| 6117 | if (power_up) |
| 6118 | val |= 1 << 11; |
| 6119 | else |
| 6120 | val &= ~(1 << 11); |
| 6121 | alc_write_coef_idx(codec, 0x04, val); |
| 6122 | } |
| 6123 | |
| 6124 | static void alc269_shutup(struct hda_codec *codec) |
| 6125 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6126 | struct alc_spec *spec = codec->spec; |
| 6127 | |
| 6128 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 6129 | return; |
| 6130 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6131 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6132 | alc269vb_toggle_power_output(codec, 0); |
| 6133 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
| 6134 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6135 | msleep(150); |
| 6136 | } |
| 6137 | } |
| 6138 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6139 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6140 | static int alc269_resume(struct hda_codec *codec) |
| 6141 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6142 | struct alc_spec *spec = codec->spec; |
| 6143 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6144 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6145 | alc269vb_toggle_power_output(codec, 0); |
| 6146 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6147 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6148 | msleep(150); |
| 6149 | } |
| 6150 | |
| 6151 | codec->patch_ops.init(codec); |
| 6152 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6153 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6154 | alc269vb_toggle_power_output(codec, 1); |
| 6155 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6156 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6157 | msleep(200); |
| 6158 | } |
| 6159 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6160 | snd_hda_codec_resume_amp(codec); |
| 6161 | snd_hda_codec_resume_cache(codec); |
| 6162 | hda_call_check_power_status(codec, 0x01); |
| 6163 | return 0; |
| 6164 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6165 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6166 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6167 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 6168 | const struct alc_fixup *fix, int action) |
| 6169 | { |
| 6170 | struct alc_spec *spec = codec->spec; |
| 6171 | |
| 6172 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6173 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6174 | } |
| 6175 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6176 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 6177 | const struct alc_fixup *fix, int action) |
| 6178 | { |
| 6179 | int coef; |
| 6180 | |
| 6181 | if (action != ALC_FIXUP_ACT_INIT) |
| 6182 | return; |
| 6183 | coef = alc_read_coef_idx(codec, 0x1e); |
| 6184 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 6185 | } |
| 6186 | |
| 6187 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 6188 | const struct alc_fixup *fix, int action) |
| 6189 | { |
| 6190 | static const struct hda_verb verbs[] = { |
| 6191 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 6192 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 6193 | {} |
| 6194 | }; |
| 6195 | unsigned int cfg; |
| 6196 | |
| 6197 | if (strcmp(codec->chip_name, "ALC271X")) |
| 6198 | return; |
| 6199 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 6200 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 6201 | snd_hda_sequence_write(codec, verbs); |
| 6202 | } |
| 6203 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6204 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 6205 | const struct alc_fixup *fix, int action) |
| 6206 | { |
| 6207 | struct alc_spec *spec = codec->spec; |
| 6208 | |
| 6209 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6210 | return; |
| 6211 | |
| 6212 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 6213 | * fix the sample rate of analog I/O to 44.1kHz |
| 6214 | */ |
| 6215 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 6216 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 6217 | } |
| 6218 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6219 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 6220 | const struct alc_fixup *fix, int action) |
| 6221 | { |
| 6222 | int coef; |
| 6223 | |
| 6224 | if (action != ALC_FIXUP_ACT_INIT) |
| 6225 | return; |
| 6226 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 6227 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 6228 | * Below is a workaround specific to ALC269 to control the dmic |
| 6229 | * signal source as mono. |
| 6230 | */ |
| 6231 | coef = alc_read_coef_idx(codec, 0x07); |
| 6232 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 6233 | } |
| 6234 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6235 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 6236 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 6237 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6238 | |
| 6239 | snd_hda_codec_write(codec, 0x20, 0, |
| 6240 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6241 | snd_hda_codec_write(codec, 0x20, 0, |
| 6242 | AC_VERB_SET_PROC_COEF, 0x680); |
| 6243 | |
| 6244 | snd_hda_codec_write(codec, 0x20, 0, |
| 6245 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6246 | snd_hda_codec_write(codec, 0x20, 0, |
| 6247 | AC_VERB_SET_PROC_COEF, 0x480); |
| 6248 | } |
| 6249 | |
| 6250 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 6251 | const struct alc_fixup *fix, int action) |
| 6252 | { |
| 6253 | struct alc_spec *spec = codec->spec; |
| 6254 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6255 | return; |
| 6256 | spec->automute_hook = alc269_quanta_automute; |
| 6257 | } |
| 6258 | |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6259 | /* update mute-LED according to the speaker mute state via mic1 VREF pin */ |
| 6260 | static void alc269_fixup_mic1_mute_hook(void *private_data, int enabled) |
| 6261 | { |
| 6262 | struct hda_codec *codec = private_data; |
| 6263 | unsigned int pinval = AC_PINCTL_IN_EN + (enabled ? |
| 6264 | AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); |
| 6265 | snd_hda_set_pin_ctl_cache(codec, 0x18, pinval); |
| 6266 | } |
| 6267 | |
| 6268 | static void alc269_fixup_mic1_mute(struct hda_codec *codec, |
| 6269 | const struct alc_fixup *fix, int action) |
| 6270 | { |
| 6271 | struct alc_spec *spec = codec->spec; |
| 6272 | switch (action) { |
| 6273 | case ALC_FIXUP_ACT_BUILD: |
| 6274 | spec->vmaster_mute.hook = alc269_fixup_mic1_mute_hook; |
| 6275 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
| 6276 | /* fallthru */ |
| 6277 | case ALC_FIXUP_ACT_INIT: |
| 6278 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 6279 | break; |
| 6280 | } |
| 6281 | } |
| 6282 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6283 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 6284 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 6285 | { |
| 6286 | struct hda_codec *codec = private_data; |
| 6287 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6288 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6289 | } |
| 6290 | |
| 6291 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 6292 | const struct alc_fixup *fix, int action) |
| 6293 | { |
| 6294 | struct alc_spec *spec = codec->spec; |
| 6295 | switch (action) { |
| 6296 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6297 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735cb | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 6298 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6299 | /* fallthru */ |
| 6300 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6301 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6302 | break; |
| 6303 | } |
| 6304 | } |
| 6305 | |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6306 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
| 6307 | const struct alc_fixup *fix, |
| 6308 | int action) |
| 6309 | { |
| 6310 | struct alc_spec *spec = codec->spec; |
| 6311 | |
| 6312 | if (action == ALC_FIXUP_ACT_PROBE) |
| 6313 | snd_hda_jack_set_gating_jack(codec, spec->ext_mic_pin, |
| 6314 | spec->autocfg.hp_pins[0]); |
| 6315 | } |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6316 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6317 | enum { |
| 6318 | ALC269_FIXUP_SONY_VAIO, |
| 6319 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 6320 | ALC269_FIXUP_DELL_M101Z, |
| 6321 | ALC269_FIXUP_SKU_IGNORE, |
| 6322 | ALC269_FIXUP_ASUS_G73JW, |
| 6323 | ALC269_FIXUP_LENOVO_EAPD, |
| 6324 | ALC275_FIXUP_SONY_HWEQ, |
| 6325 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6326 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6327 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6328 | ALC269_FIXUP_QUANTA_MUTE, |
| 6329 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6330 | ALC269_FIXUP_AMIC, |
| 6331 | ALC269_FIXUP_DMIC, |
| 6332 | ALC269VB_FIXUP_AMIC, |
| 6333 | ALC269VB_FIXUP_DMIC, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6334 | ALC269_FIXUP_MIC1_MUTE_LED, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6335 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6336 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6337 | ALC269_FIXUP_LENOVO_DOCK, |
| 6338 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6339 | ALC271_FIXUP_AMIC_MIC2, |
| 6340 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6341 | }; |
| 6342 | |
| 6343 | static const struct alc_fixup alc269_fixups[] = { |
| 6344 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6345 | .type = ALC_FIXUP_VERBS, |
| 6346 | .v.verbs = (const struct hda_verb[]) { |
| 6347 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6348 | {} |
| 6349 | } |
| 6350 | }, |
| 6351 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6352 | .type = ALC_FIXUP_VERBS, |
| 6353 | .v.verbs = (const struct hda_verb[]) { |
| 6354 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6355 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6356 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6357 | { } |
| 6358 | }, |
| 6359 | .chained = true, |
| 6360 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6361 | }, |
| 6362 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6363 | .type = ALC_FIXUP_VERBS, |
| 6364 | .v.verbs = (const struct hda_verb[]) { |
| 6365 | /* Enables internal speaker */ |
| 6366 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6367 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6368 | {} |
| 6369 | } |
| 6370 | }, |
| 6371 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6372 | .type = ALC_FIXUP_FUNC, |
| 6373 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6374 | }, |
| 6375 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6376 | .type = ALC_FIXUP_PINS, |
| 6377 | .v.pins = (const struct alc_pincfg[]) { |
| 6378 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6379 | { } |
| 6380 | } |
| 6381 | }, |
| 6382 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6383 | .type = ALC_FIXUP_VERBS, |
| 6384 | .v.verbs = (const struct hda_verb[]) { |
| 6385 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6386 | {} |
| 6387 | } |
| 6388 | }, |
| 6389 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6390 | .type = ALC_FIXUP_FUNC, |
| 6391 | .v.func = alc269_fixup_hweq, |
| 6392 | .chained = true, |
| 6393 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6394 | }, |
| 6395 | [ALC271_FIXUP_DMIC] = { |
| 6396 | .type = ALC_FIXUP_FUNC, |
| 6397 | .v.func = alc271_fixup_dmic, |
| 6398 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6399 | [ALC269_FIXUP_PCM_44K] = { |
| 6400 | .type = ALC_FIXUP_FUNC, |
| 6401 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6402 | .chained = true, |
| 6403 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6404 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6405 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6406 | .type = ALC_FIXUP_FUNC, |
| 6407 | .v.func = alc269_fixup_stereo_dmic, |
| 6408 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6409 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6410 | .type = ALC_FIXUP_FUNC, |
| 6411 | .v.func = alc269_fixup_quanta_mute, |
| 6412 | }, |
| 6413 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6414 | .type = ALC_FIXUP_PINS, |
| 6415 | .v.pins = (const struct alc_pincfg[]) { |
| 6416 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6417 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6418 | { } |
| 6419 | }, |
| 6420 | .chained = true, |
| 6421 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6422 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6423 | [ALC269_FIXUP_AMIC] = { |
| 6424 | .type = ALC_FIXUP_PINS, |
| 6425 | .v.pins = (const struct alc_pincfg[]) { |
| 6426 | { 0x14, 0x99130110 }, /* speaker */ |
| 6427 | { 0x15, 0x0121401f }, /* HP out */ |
| 6428 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6429 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6430 | { } |
| 6431 | }, |
| 6432 | }, |
| 6433 | [ALC269_FIXUP_DMIC] = { |
| 6434 | .type = ALC_FIXUP_PINS, |
| 6435 | .v.pins = (const struct alc_pincfg[]) { |
| 6436 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6437 | { 0x14, 0x99130110 }, /* speaker */ |
| 6438 | { 0x15, 0x0121401f }, /* HP out */ |
| 6439 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6440 | { } |
| 6441 | }, |
| 6442 | }, |
| 6443 | [ALC269VB_FIXUP_AMIC] = { |
| 6444 | .type = ALC_FIXUP_PINS, |
| 6445 | .v.pins = (const struct alc_pincfg[]) { |
| 6446 | { 0x14, 0x99130110 }, /* speaker */ |
| 6447 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6448 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6449 | { 0x21, 0x0121401f }, /* HP out */ |
| 6450 | { } |
| 6451 | }, |
| 6452 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6453 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6454 | .type = ALC_FIXUP_PINS, |
| 6455 | .v.pins = (const struct alc_pincfg[]) { |
| 6456 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6457 | { 0x14, 0x99130110 }, /* speaker */ |
| 6458 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6459 | { 0x21, 0x0121401f }, /* HP out */ |
| 6460 | { } |
| 6461 | }, |
| 6462 | }, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6463 | [ALC269_FIXUP_MIC1_MUTE_LED] = { |
| 6464 | .type = ALC_FIXUP_FUNC, |
| 6465 | .v.func = alc269_fixup_mic1_mute, |
| 6466 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6467 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6468 | .type = ALC_FIXUP_FUNC, |
| 6469 | .v.func = alc269_fixup_mic2_mute, |
| 6470 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6471 | [ALC269_FIXUP_INV_DMIC] = { |
| 6472 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6473 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6474 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6475 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6476 | .type = ALC_FIXUP_PINS, |
| 6477 | .v.pins = (const struct alc_pincfg[]) { |
| 6478 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6479 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6480 | { } |
| 6481 | }, |
| 6482 | .chained = true, |
| 6483 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6484 | }, |
| 6485 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6486 | .type = ALC_FIXUP_FUNC, |
| 6487 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6488 | }, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6489 | [ALC271_FIXUP_AMIC_MIC2] = { |
| 6490 | .type = ALC_FIXUP_PINS, |
| 6491 | .v.pins = (const struct alc_pincfg[]) { |
| 6492 | { 0x14, 0x99130110 }, /* speaker */ |
| 6493 | { 0x19, 0x01a19c20 }, /* mic */ |
| 6494 | { 0x1b, 0x99a7012f }, /* int-mic */ |
| 6495 | { 0x21, 0x0121401f }, /* HP out */ |
| 6496 | { } |
| 6497 | }, |
| 6498 | }, |
| 6499 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { |
| 6500 | .type = ALC_FIXUP_FUNC, |
| 6501 | .v.func = alc271_hp_gate_mic_jack, |
| 6502 | .chained = true, |
| 6503 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
| 6504 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6505 | }; |
| 6506 | |
| 6507 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6508 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6509 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6510 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6511 | 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] | 6512 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6513 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6514 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6515 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6516 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6517 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6518 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6519 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6520 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6521 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6522 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6523 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6524 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6525 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6526 | 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] | 6527 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6528 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6529 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6530 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6531 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6532 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6533 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6534 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6535 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Stefán Freyr | 84f98fd | 2012-10-19 22:46:00 +0200 | [diff] [blame] | 6536 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6537 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6538 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6539 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6540 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6541 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6542 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6543 | /* Below is a quirk table taken from the old code. |
| 6544 | * Basically the device should work as is without the fixup table. |
| 6545 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6546 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6547 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6548 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6549 | ALC269_FIXUP_AMIC), |
| 6550 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6551 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6552 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6553 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6554 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6555 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6556 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6557 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6558 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6559 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6560 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6561 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6562 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6563 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6564 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6565 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6566 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6567 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6568 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6569 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6570 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6571 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6572 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6573 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6574 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6575 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6576 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6577 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6578 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6579 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6580 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6581 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6582 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6583 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6584 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6585 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6586 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6587 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6588 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6589 | #endif |
| 6590 | {} |
| 6591 | }; |
| 6592 | |
| 6593 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6594 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6595 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6596 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6597 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6598 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6599 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6600 | {} |
| 6601 | }; |
| 6602 | |
| 6603 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6604 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6605 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6606 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6607 | int val; |
| 6608 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6609 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6610 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6611 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6612 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6613 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6614 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6615 | } |
| 6616 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6617 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6618 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6619 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6620 | } |
| 6621 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6622 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6623 | val = alc_read_coef_idx(codec, 0x04); |
| 6624 | /* Power up output pin */ |
| 6625 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6626 | } |
| 6627 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6628 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6629 | val = alc_read_coef_idx(codec, 0xd); |
| 6630 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6631 | /* Capless ramp up clock control */ |
| 6632 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6633 | } |
| 6634 | val = alc_read_coef_idx(codec, 0x17); |
| 6635 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6636 | /* Class D power on reset */ |
| 6637 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6638 | } |
| 6639 | } |
| 6640 | |
| 6641 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6642 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6643 | |
| 6644 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6645 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6646 | } |
| 6647 | |
| 6648 | /* |
| 6649 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6650 | static int patch_alc269(struct hda_codec *codec) |
| 6651 | { |
| 6652 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6653 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6654 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6655 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6656 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6657 | return err; |
| 6658 | |
| 6659 | spec = codec->spec; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6660 | |
Herton Ronaldo Krzesinski | 9f720bb9 | 2012-09-27 10:38:14 -0300 | [diff] [blame] | 6661 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6662 | alc269_fixup_tbl, alc269_fixups); |
| 6663 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6664 | |
| 6665 | alc_auto_parse_customize_define(codec); |
| 6666 | |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6667 | switch (codec->vendor_id) { |
| 6668 | case 0x10ec0269: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6669 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6670 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6671 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6672 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6673 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6674 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6675 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6676 | break; |
| 6677 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6678 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6679 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6680 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6681 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6682 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6683 | case 0x0030: |
| 6684 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6685 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6686 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6687 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6688 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6689 | if (err < 0) |
| 6690 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6691 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6692 | alc269_fill_coef(codec); |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6693 | break; |
| 6694 | |
| 6695 | case 0x10ec0280: |
| 6696 | case 0x10ec0290: |
| 6697 | spec->codec_variant = ALC269_TYPE_ALC280; |
| 6698 | break; |
| 6699 | case 0x10ec0282: |
| 6700 | case 0x10ec0283: |
| 6701 | spec->codec_variant = ALC269_TYPE_ALC282; |
| 6702 | break; |
| 6703 | case 0x10ec0284: |
| 6704 | case 0x10ec0292: |
| 6705 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 6706 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6707 | } |
| 6708 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6709 | /* automatic parse from the BIOS config */ |
| 6710 | err = alc269_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 && has_cdefine_beep(codec)) { |
| 6715 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6716 | if (err < 0) |
| 6717 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6718 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 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 | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6722 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6723 | codec->patch_ops.resume = alc269_resume; |
| 6724 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6725 | spec->shutup = alc269_shutup; |
| 6726 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6727 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6728 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6729 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6730 | |
| 6731 | error: |
| 6732 | alc_free(codec); |
| 6733 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6734 | } |
| 6735 | |
| 6736 | /* |
| 6737 | * ALC861 |
| 6738 | */ |
| 6739 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6740 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6741 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6742 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6743 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6744 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6745 | } |
| 6746 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6747 | /* Pin config fixes */ |
| 6748 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6749 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6750 | ALC861_FIXUP_AMP_VREF_0F, |
| 6751 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6752 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6753 | }; |
| 6754 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6755 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6756 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6757 | const struct alc_fixup *fix, int action) |
| 6758 | { |
| 6759 | struct alc_spec *spec = codec->spec; |
| 6760 | unsigned int val; |
| 6761 | |
| 6762 | if (action != ALC_FIXUP_ACT_INIT) |
| 6763 | return; |
| 6764 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6765 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6766 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6767 | val |= AC_PINCTL_IN_EN; |
| 6768 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6769 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6770 | spec->keep_vref_in_automute = 1; |
| 6771 | } |
| 6772 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6773 | /* suppress the jack-detection */ |
| 6774 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6775 | const struct alc_fixup *fix, int action) |
| 6776 | { |
| 6777 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6778 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6779 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6780 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6781 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6782 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6783 | .type = ALC_FIXUP_PINS, |
| 6784 | .v.pins = (const struct alc_pincfg[]) { |
| 6785 | { 0x0b, 0x0221101f }, /* HP */ |
| 6786 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6787 | { } |
| 6788 | } |
| 6789 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6790 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6791 | .type = ALC_FIXUP_FUNC, |
| 6792 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6793 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6794 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6795 | .type = ALC_FIXUP_FUNC, |
| 6796 | .v.func = alc_fixup_no_jack_detect, |
| 6797 | }, |
| 6798 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6799 | .type = ALC_FIXUP_FUNC, |
| 6800 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6801 | .chained = true, |
| 6802 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6803 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6804 | }; |
| 6805 | |
| 6806 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6807 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6808 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6809 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6810 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6811 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6812 | 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] | 6813 | {} |
| 6814 | }; |
| 6815 | |
| 6816 | /* |
| 6817 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6818 | static int patch_alc861(struct hda_codec *codec) |
| 6819 | { |
| 6820 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6821 | int err; |
| 6822 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6823 | err = alc_alloc_spec(codec, 0x15); |
| 6824 | if (err < 0) |
| 6825 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6826 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6827 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6828 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6829 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6830 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6831 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6832 | /* automatic parse from the BIOS config */ |
| 6833 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6834 | if (err < 0) |
| 6835 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6836 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6837 | if (!spec->no_analog) { |
| 6838 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6839 | if (err < 0) |
| 6840 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6841 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6842 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6843 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6844 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6845 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6846 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6847 | #endif |
| 6848 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6849 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6850 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6851 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6852 | |
| 6853 | error: |
| 6854 | alc_free(codec); |
| 6855 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6856 | } |
| 6857 | |
| 6858 | /* |
| 6859 | * ALC861-VD support |
| 6860 | * |
| 6861 | * Based on ALC882 |
| 6862 | * |
| 6863 | * In addition, an independent DAC |
| 6864 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6865 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6866 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6867 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6868 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6869 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6870 | } |
| 6871 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6872 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6873 | ALC660VD_FIX_ASUS_GPIO1, |
| 6874 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6875 | }; |
| 6876 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6877 | /* exclude VREF80 */ |
| 6878 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6879 | const struct alc_fixup *fix, int action) |
| 6880 | { |
| 6881 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | b78562b | 2012-12-17 20:06:49 +0100 | [diff] [blame] | 6882 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
| 6883 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6884 | } |
| 6885 | } |
| 6886 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6887 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6888 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6889 | .type = ALC_FIXUP_VERBS, |
| 6890 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6891 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6892 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6893 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6894 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6895 | { } |
| 6896 | } |
| 6897 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6898 | [ALC861VD_FIX_DALLAS] = { |
| 6899 | .type = ALC_FIXUP_FUNC, |
| 6900 | .v.func = alc861vd_fixup_dallas, |
| 6901 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6902 | }; |
| 6903 | |
| 6904 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6905 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6906 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6907 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6908 | {} |
| 6909 | }; |
| 6910 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6911 | /* |
| 6912 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6913 | static int patch_alc861vd(struct hda_codec *codec) |
| 6914 | { |
| 6915 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6916 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6917 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6918 | err = alc_alloc_spec(codec, 0x0b); |
| 6919 | if (err < 0) |
| 6920 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6921 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6922 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6923 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6924 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6925 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6926 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6927 | /* automatic parse from the BIOS config */ |
| 6928 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6929 | if (err < 0) |
| 6930 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6931 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6932 | if (!spec->no_analog) { |
| 6933 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6934 | if (err < 0) |
| 6935 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6936 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6937 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6938 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6939 | codec->patch_ops = alc_patch_ops; |
| 6940 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6941 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6942 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6943 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6944 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6945 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6946 | |
| 6947 | error: |
| 6948 | alc_free(codec); |
| 6949 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6950 | } |
| 6951 | |
| 6952 | /* |
| 6953 | * ALC662 support |
| 6954 | * |
| 6955 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6956 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6957 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6958 | * 6-channel independent captures. |
| 6959 | * |
| 6960 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6961 | * driver yet). |
| 6962 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6963 | |
| 6964 | /* |
| 6965 | * BIOS auto configuration |
| 6966 | */ |
| 6967 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6968 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6969 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6970 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6971 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6972 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6973 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6974 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6975 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6976 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6977 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6978 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6979 | ssids = alc662_ssids; |
| 6980 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6981 | } |
| 6982 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6983 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6984 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6985 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6986 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6987 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6988 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6989 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6990 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6991 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6992 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6993 | printk(KERN_WARNING |
| 6994 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6995 | } |
| 6996 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6997 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6998 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6999 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7000 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7001 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7002 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7003 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7004 | ALC662_FIXUP_ASUS_MODE1, |
| 7005 | ALC662_FIXUP_ASUS_MODE2, |
| 7006 | ALC662_FIXUP_ASUS_MODE3, |
| 7007 | ALC662_FIXUP_ASUS_MODE4, |
| 7008 | ALC662_FIXUP_ASUS_MODE5, |
| 7009 | ALC662_FIXUP_ASUS_MODE6, |
| 7010 | ALC662_FIXUP_ASUS_MODE7, |
| 7011 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7012 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7013 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7014 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7015 | }; |
| 7016 | |
| 7017 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7018 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7019 | .type = ALC_FIXUP_PINS, |
| 7020 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7021 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 7022 | { } |
| 7023 | } |
| 7024 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7025 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7026 | .type = ALC_FIXUP_PINS, |
| 7027 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7028 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 7029 | { } |
| 7030 | } |
| 7031 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7032 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 7033 | .type = ALC_FIXUP_FUNC, |
| 7034 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7035 | }, |
| 7036 | [ALC662_FIXUP_CZC_P10T] = { |
| 7037 | .type = ALC_FIXUP_VERBS, |
| 7038 | .v.verbs = (const struct hda_verb[]) { |
| 7039 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 7040 | {} |
| 7041 | } |
| 7042 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7043 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 7044 | .type = ALC_FIXUP_FUNC, |
| 7045 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 7046 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7047 | [ALC662_FIXUP_HP_RP5800] = { |
| 7048 | .type = ALC_FIXUP_PINS, |
| 7049 | .v.pins = (const struct alc_pincfg[]) { |
| 7050 | { 0x14, 0x0221201f }, /* HP out */ |
| 7051 | { } |
| 7052 | }, |
| 7053 | .chained = true, |
| 7054 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7055 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7056 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 7057 | .type = ALC_FIXUP_PINS, |
| 7058 | .v.pins = (const struct alc_pincfg[]) { |
| 7059 | { 0x14, 0x99130110 }, /* speaker */ |
| 7060 | { 0x18, 0x01a19c20 }, /* mic */ |
| 7061 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 7062 | { 0x21, 0x0121401f }, /* HP out */ |
| 7063 | { } |
| 7064 | }, |
| 7065 | .chained = true, |
| 7066 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7067 | }, |
| 7068 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7069 | .type = ALC_FIXUP_PINS, |
| 7070 | .v.pins = (const struct alc_pincfg[]) { |
| 7071 | { 0x14, 0x99130110 }, /* speaker */ |
| 7072 | { 0x18, 0x01a19820 }, /* mic */ |
| 7073 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 7074 | { 0x1b, 0x0121401f }, /* HP out */ |
| 7075 | { } |
| 7076 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7077 | .chained = true, |
| 7078 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7079 | }, |
| 7080 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 7081 | .type = ALC_FIXUP_PINS, |
| 7082 | .v.pins = (const struct alc_pincfg[]) { |
| 7083 | { 0x14, 0x99130110 }, /* speaker */ |
| 7084 | { 0x15, 0x0121441f }, /* HP */ |
| 7085 | { 0x18, 0x01a19840 }, /* mic */ |
| 7086 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7087 | { 0x21, 0x01211420 }, /* HP2 */ |
| 7088 | { } |
| 7089 | }, |
| 7090 | .chained = true, |
| 7091 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7092 | }, |
| 7093 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 7094 | .type = ALC_FIXUP_PINS, |
| 7095 | .v.pins = (const struct alc_pincfg[]) { |
| 7096 | { 0x14, 0x99130110 }, /* speaker */ |
| 7097 | { 0x16, 0x99130111 }, /* speaker */ |
| 7098 | { 0x18, 0x01a19840 }, /* mic */ |
| 7099 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7100 | { 0x21, 0x0121441f }, /* HP */ |
| 7101 | { } |
| 7102 | }, |
| 7103 | .chained = true, |
| 7104 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7105 | }, |
| 7106 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 7107 | .type = ALC_FIXUP_PINS, |
| 7108 | .v.pins = (const struct alc_pincfg[]) { |
| 7109 | { 0x14, 0x99130110 }, /* speaker */ |
| 7110 | { 0x15, 0x0121441f }, /* HP */ |
| 7111 | { 0x16, 0x99130111 }, /* speaker */ |
| 7112 | { 0x18, 0x01a19840 }, /* mic */ |
| 7113 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7114 | { } |
| 7115 | }, |
| 7116 | .chained = true, |
| 7117 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7118 | }, |
| 7119 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 7120 | .type = ALC_FIXUP_PINS, |
| 7121 | .v.pins = (const struct alc_pincfg[]) { |
| 7122 | { 0x14, 0x99130110 }, /* speaker */ |
| 7123 | { 0x15, 0x01211420 }, /* HP2 */ |
| 7124 | { 0x18, 0x01a19840 }, /* mic */ |
| 7125 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7126 | { 0x1b, 0x0121441f }, /* HP */ |
| 7127 | { } |
| 7128 | }, |
| 7129 | .chained = true, |
| 7130 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7131 | }, |
| 7132 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 7133 | .type = ALC_FIXUP_PINS, |
| 7134 | .v.pins = (const struct alc_pincfg[]) { |
| 7135 | { 0x14, 0x99130110 }, /* speaker */ |
| 7136 | { 0x17, 0x99130111 }, /* speaker */ |
| 7137 | { 0x18, 0x01a19840 }, /* mic */ |
| 7138 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7139 | { 0x1b, 0x01214020 }, /* HP */ |
| 7140 | { 0x21, 0x0121401f }, /* HP */ |
| 7141 | { } |
| 7142 | }, |
| 7143 | .chained = true, |
| 7144 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7145 | }, |
| 7146 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 7147 | .type = ALC_FIXUP_PINS, |
| 7148 | .v.pins = (const struct alc_pincfg[]) { |
| 7149 | { 0x14, 0x99130110 }, /* speaker */ |
| 7150 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 7151 | { 0x15, 0x01214020 }, /* HP */ |
| 7152 | { 0x17, 0x99130111 }, /* speaker */ |
| 7153 | { 0x18, 0x01a19840 }, /* mic */ |
| 7154 | { 0x21, 0x0121401f }, /* HP */ |
| 7155 | { } |
| 7156 | }, |
| 7157 | .chained = true, |
| 7158 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7159 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7160 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 7161 | .type = ALC_FIXUP_FUNC, |
| 7162 | .v.func = alc_fixup_no_jack_detect, |
| 7163 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7164 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 7165 | .type = ALC_FIXUP_PINS, |
| 7166 | .v.pins = (const struct alc_pincfg[]) { |
| 7167 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 7168 | { } |
| 7169 | } |
| 7170 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7171 | [ALC662_FIXUP_INV_DMIC] = { |
| 7172 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7173 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7174 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7175 | }; |
| 7176 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7177 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7178 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 7179 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7180 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7181 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7182 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7183 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7184 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7185 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 7186 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 7187 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7188 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7189 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7190 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7191 | |
| 7192 | #if 0 |
| 7193 | /* Below is a quirk table taken from the old code. |
| 7194 | * Basically the device should work as is without the fixup table. |
| 7195 | * If BIOS doesn't give a proper info, enable the corresponding |
| 7196 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 7197 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7198 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 7199 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 7200 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 7201 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 7202 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7203 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7204 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7205 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 7206 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 7207 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7208 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 7209 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 7210 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 7211 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 7212 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 7213 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7214 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 7215 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 7216 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7217 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7218 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7219 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7220 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 7221 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 7222 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 7223 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7224 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 7225 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7226 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7227 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 7228 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7229 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7230 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 7231 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 7232 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 7233 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 7234 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 7235 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 7236 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 7237 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7238 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 7239 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 7240 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7241 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 7242 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 7243 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 7244 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 7245 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 7246 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7247 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 7248 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7249 | {} |
| 7250 | }; |
| 7251 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7252 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 7253 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7254 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 7255 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 7256 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 7257 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 7258 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 7259 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 7260 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 7261 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7262 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7263 | {} |
| 7264 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7265 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7266 | static void alc662_fill_coef(struct hda_codec *codec) |
| 7267 | { |
| 7268 | int val, coef; |
| 7269 | |
| 7270 | coef = alc_get_coef0(codec); |
| 7271 | |
| 7272 | switch (codec->vendor_id) { |
| 7273 | case 0x10ec0662: |
| 7274 | if ((coef & 0x00f0) == 0x0030) { |
| 7275 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 7276 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 7277 | } |
| 7278 | break; |
| 7279 | case 0x10ec0272: |
| 7280 | case 0x10ec0273: |
| 7281 | case 0x10ec0663: |
| 7282 | case 0x10ec0665: |
| 7283 | case 0x10ec0670: |
| 7284 | case 0x10ec0671: |
| 7285 | case 0x10ec0672: |
| 7286 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 7287 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 7288 | break; |
| 7289 | } |
| 7290 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7291 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7292 | /* |
| 7293 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7294 | static int patch_alc662(struct hda_codec *codec) |
| 7295 | { |
| 7296 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7297 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7298 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7299 | err = alc_alloc_spec(codec, 0x0b); |
| 7300 | if (err < 0) |
| 7301 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7302 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7303 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7304 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7305 | /* handle multiple HPs as is */ |
| 7306 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 7307 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 7308 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 7309 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7310 | spec->init_hook = alc662_fill_coef; |
| 7311 | alc662_fill_coef(codec); |
| 7312 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 7313 | alc_pick_fixup(codec, alc662_fixup_models, |
| 7314 | alc662_fixup_tbl, alc662_fixups); |
| 7315 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 7316 | |
| 7317 | alc_auto_parse_customize_define(codec); |
| 7318 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 7319 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7320 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 7321 | spec->cdefine.platform_type == 1) { |
| 7322 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 7323 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 7324 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7325 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 7326 | /* automatic parse from the BIOS config */ |
| 7327 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7328 | if (err < 0) |
| 7329 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7330 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7331 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 7332 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7333 | if (err < 0) |
| 7334 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 7335 | switch (codec->vendor_id) { |
| 7336 | case 0x10ec0662: |
| 7337 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 7338 | break; |
| 7339 | case 0x10ec0272: |
| 7340 | case 0x10ec0663: |
| 7341 | case 0x10ec0665: |
| 7342 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 7343 | break; |
| 7344 | case 0x10ec0273: |
| 7345 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 7346 | break; |
| 7347 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7348 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 7349 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7350 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 7351 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7352 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 7353 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 7354 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7355 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7356 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7357 | error: |
| 7358 | alc_free(codec); |
| 7359 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 7360 | } |
| 7361 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7362 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7363 | * ALC680 support |
| 7364 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7365 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7366 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7367 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7368 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7369 | } |
| 7370 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7371 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7372 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7373 | static int patch_alc680(struct hda_codec *codec) |
| 7374 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7375 | int err; |
| 7376 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7377 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7378 | err = alc_alloc_spec(codec, 0); |
| 7379 | if (err < 0) |
| 7380 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7381 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7382 | /* automatic parse from the BIOS config */ |
| 7383 | err = alc680_parse_auto_config(codec); |
| 7384 | if (err < 0) { |
| 7385 | alc_free(codec); |
| 7386 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7387 | } |
| 7388 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7389 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7390 | |
| 7391 | return 0; |
| 7392 | } |
| 7393 | |
| 7394 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7395 | * patch entries |
| 7396 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7397 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7398 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7399 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7400 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7401 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7402 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7403 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7404 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7405 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7406 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7407 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7408 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7409 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7410 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 7411 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7412 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
David Henningsson | af02dde | 2012-11-21 08:57:58 +0100 | [diff] [blame] | 7413 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7414 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7415 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7416 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7417 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7418 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7419 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7420 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7421 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7422 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7423 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7424 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7425 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7426 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7427 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7428 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7429 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7430 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7431 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7432 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7433 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7434 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7435 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7436 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7437 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7438 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7439 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7440 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7441 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7442 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7443 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7444 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7445 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7446 | {} /* terminator */ |
| 7447 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7448 | |
| 7449 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7450 | |
| 7451 | MODULE_LICENSE("GPL"); |
| 7452 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7453 | |
| 7454 | static struct hda_codec_preset_list realtek_list = { |
| 7455 | .preset = snd_hda_preset_realtek, |
| 7456 | .owner = THIS_MODULE, |
| 7457 | }; |
| 7458 | |
| 7459 | static int __init patch_realtek_init(void) |
| 7460 | { |
| 7461 | return snd_hda_add_codec_preset(&realtek_list); |
| 7462 | } |
| 7463 | |
| 7464 | static void __exit patch_realtek_exit(void) |
| 7465 | { |
| 7466 | snd_hda_delete_codec_preset(&realtek_list); |
| 7467 | } |
| 7468 | |
| 7469 | module_init(patch_realtek_init) |
| 7470 | module_exit(patch_realtek_exit) |