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 | 7cf51e48 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
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" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 35 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 36 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 38 | /* unsol event tags */ |
| 39 | #define ALC_FRONT_EVENT 0x01 |
| 40 | #define ALC_DCVOL_EVENT 0x02 |
| 41 | #define ALC_HP_EVENT 0x04 |
| 42 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 43 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 44 | /* for GPIO Poll */ |
| 45 | #define GPIO_MASK 0x03 |
| 46 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 47 | /* extra amp-initialization sequence types */ |
| 48 | enum { |
| 49 | ALC_INIT_NONE, |
| 50 | ALC_INIT_DEFAULT, |
| 51 | ALC_INIT_GPIO1, |
| 52 | ALC_INIT_GPIO2, |
| 53 | ALC_INIT_GPIO3, |
| 54 | }; |
| 55 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 56 | struct alc_customize_define { |
| 57 | unsigned int sku_cfg; |
| 58 | unsigned char port_connectivity; |
| 59 | unsigned char check_sum; |
| 60 | unsigned char customization; |
| 61 | unsigned char external_amp; |
| 62 | unsigned int enable_pcbeep:1; |
| 63 | unsigned int platform_type:1; |
| 64 | unsigned int swap:1; |
| 65 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 66 | 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] | 67 | }; |
| 68 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 69 | struct alc_fixup; |
| 70 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 71 | struct alc_multi_io { |
| 72 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 73 | hda_nid_t dac; /* DAC to be connected */ |
| 74 | unsigned int ctl_in; /* cached input-pin control value */ |
| 75 | }; |
| 76 | |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 77 | enum { |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 78 | ALC_AUTOMUTE_PIN, /* change the pin control */ |
| 79 | ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */ |
| 80 | ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | struct alc_spec { |
| 84 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 85 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 87 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 88 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Takashi Iwai | 2d9c648 | 2009-10-13 08:06:55 +0200 | [diff] [blame] | 90 | const struct hda_verb *init_verbs[10]; /* initialization verbs |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 91 | * don't forget NULL |
| 92 | * termination! |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 93 | */ |
| 94 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 96 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 97 | const struct hda_pcm_stream *stream_analog_playback; |
| 98 | const struct hda_pcm_stream *stream_analog_capture; |
| 99 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 100 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 102 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 103 | const struct hda_pcm_stream *stream_digital_playback; |
| 104 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 107 | struct hda_multi_out multiout; /* playback set-up |
| 108 | * max_channels, dacs must be set |
| 109 | * dig_out_nid and hp_nid are optional |
| 110 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 111 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 112 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 113 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | /* capture */ |
| 116 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 117 | const hda_nid_t *adc_nids; |
| 118 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 119 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 120 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 121 | DECLARE_BITMAP(vol_ctls, 0x20 << 1); |
| 122 | DECLARE_BITMAP(sw_ctls, 0x20 << 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 124 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 125 | hda_nid_t cur_adc; |
| 126 | unsigned int cur_adc_stream_tag; |
| 127 | unsigned int cur_adc_format; |
| 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 130 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | const struct hda_input_mux *input_mux; |
| 132 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 133 | hda_nid_t ext_mic_pin; |
| 134 | hda_nid_t dock_mic_pin; |
| 135 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
| 137 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 138 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 140 | int need_dac_fix; |
Hector Martin | 3b315d7 | 2009-06-02 10:54:19 +0200 | [diff] [blame] | 141 | int const_channel_count; |
| 142 | int ext_channel_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
| 144 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 145 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 146 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 147 | /* dynamic controls, init_verbs and input_mux */ |
| 148 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 149 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 150 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 151 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 152 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 153 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 154 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 155 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 156 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 157 | int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 158 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 159 | /* hooks */ |
| 160 | void (*init_hook)(struct hda_codec *codec); |
| 161 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 162 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 163 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 164 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 165 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 166 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 167 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 168 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 169 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 170 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 171 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 172 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 173 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 174 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 175 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 176 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 177 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 178 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 179 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 180 | 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] | 181 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 182 | /* other flags */ |
| 183 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 184 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 185 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 186 | 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] | 187 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 188 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 189 | |
| 190 | /* auto-mute control */ |
| 191 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 192 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 193 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 194 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 195 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 196 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 197 | /* for virtual master */ |
| 198 | hda_nid_t vmaster_nid; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 199 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 200 | struct hda_loopback_check loopback; |
| 201 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 202 | |
| 203 | /* for PLL fix */ |
| 204 | hda_nid_t pll_nid; |
| 205 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 206 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 207 | |
| 208 | /* fix-up list */ |
| 209 | int fixup_id; |
| 210 | const struct alc_fixup *fixup_list; |
| 211 | const char *fixup_name; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 212 | |
| 213 | /* multi-io */ |
| 214 | int multi_ios; |
| 215 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 216 | |
| 217 | /* bind volumes */ |
| 218 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 219 | }; |
| 220 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 221 | #define ALC_MODEL_AUTO 0 /* common for all chips */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 223 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 224 | int dir, unsigned int bits) |
| 225 | { |
| 226 | if (!nid) |
| 227 | return false; |
| 228 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 229 | if (query_amp_caps(codec, nid, dir) & bits) |
| 230 | return true; |
| 231 | return false; |
| 232 | } |
| 233 | |
| 234 | #define nid_has_mute(codec, nid, dir) \ |
| 235 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 236 | #define nid_has_volume(codec, nid, dir) \ |
| 237 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 238 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | /* |
| 240 | * input MUX handling |
| 241 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 242 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 243 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
| 245 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 246 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 247 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 248 | if (mux_idx >= spec->num_mux_defs) |
| 249 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 250 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 251 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 252 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 255 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 256 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | { |
| 258 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 259 | struct alc_spec *spec = codec->spec; |
| 260 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 261 | |
| 262 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 263 | return 0; |
| 264 | } |
| 265 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 266 | 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] | 267 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 268 | struct alc_spec *spec = codec->spec; |
| 269 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 270 | |
| 271 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 272 | /* stream is running, let's swap the current ADC */ |
| 273 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 274 | spec->cur_adc = new_adc; |
| 275 | snd_hda_codec_setup_stream(codec, new_adc, |
| 276 | spec->cur_adc_stream_tag, 0, |
| 277 | spec->cur_adc_format); |
| 278 | return true; |
| 279 | } |
| 280 | return false; |
| 281 | } |
| 282 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 283 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 284 | { |
| 285 | return spec->capsrc_nids ? |
| 286 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 287 | } |
| 288 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 289 | static void call_update_outputs(struct hda_codec *codec); |
| 290 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 291 | /* select the given imux item; either unmute exclusively or select the route */ |
| 292 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 293 | unsigned int idx, bool force) |
| 294 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 296 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 297 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 298 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 299 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 301 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 302 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 303 | if (!imux->num_items && mux_idx > 0) |
| 304 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 305 | if (!imux->num_items) |
| 306 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 307 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 308 | if (idx >= imux->num_items) |
| 309 | idx = imux->num_items - 1; |
| 310 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 311 | return 0; |
| 312 | spec->cur_mux[adc_idx] = idx; |
| 313 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 314 | /* for shared I/O, change the pin-control accordingly */ |
| 315 | if (spec->shared_mic_hp) { |
| 316 | /* NOTE: this assumes that there are only two inputs, the |
| 317 | * first is the real internal mic and the second is HP jack. |
| 318 | */ |
| 319 | snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0, |
| 320 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 321 | spec->cur_mux[adc_idx] ? |
| 322 | PIN_VREF80 : PIN_HP); |
| 323 | spec->automute_speaker = !spec->cur_mux[adc_idx]; |
| 324 | call_update_outputs(codec); |
| 325 | } |
| 326 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 327 | if (spec->dyn_adc_switch) { |
| 328 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 329 | adc_idx = spec->dyn_adc_idx[idx]; |
| 330 | } |
| 331 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 332 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 333 | |
| 334 | /* no selection? */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 335 | num_conns = snd_hda_get_conn_list(codec, nid, NULL); |
| 336 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 337 | return 1; |
| 338 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 339 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 340 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 341 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 342 | int active = imux->items[idx].index; |
| 343 | for (i = 0; i < num_conns; i++) { |
| 344 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 345 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 346 | HDA_AMP_MUTE, v); |
| 347 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 348 | } else { |
| 349 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 350 | snd_hda_codec_write_cache(codec, nid, 0, |
| 351 | AC_VERB_SET_CONNECT_SEL, |
| 352 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 353 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 354 | return 1; |
| 355 | } |
| 356 | |
| 357 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 358 | struct snd_ctl_elem_value *ucontrol) |
| 359 | { |
| 360 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 361 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 362 | return alc_mux_select(codec, adc_idx, |
| 363 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 364 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 365 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 367 | * set up the input pin config (depending on the given auto-pin type) |
| 368 | */ |
| 369 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 370 | int auto_pin_type) |
| 371 | { |
| 372 | unsigned int val = PIN_IN; |
| 373 | |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 374 | if (auto_pin_type == AUTO_PIN_MIC) { |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 375 | unsigned int pincap; |
Takashi Iwai | 954a29c | 2010-07-30 10:55:44 +0200 | [diff] [blame] | 376 | unsigned int oldval; |
| 377 | oldval = snd_hda_codec_read(codec, nid, 0, |
| 378 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 379 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 380 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
Takashi Iwai | 954a29c | 2010-07-30 10:55:44 +0200 | [diff] [blame] | 381 | /* if the default pin setup is vref50, we give it priority */ |
| 382 | if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 383 | val = PIN_VREF80; |
Takashi Iwai | 461c6c3 | 2009-05-25 08:06:02 +0200 | [diff] [blame] | 384 | else if (pincap & AC_PINCAP_VREF_50) |
| 385 | val = PIN_VREF50; |
| 386 | else if (pincap & AC_PINCAP_VREF_100) |
| 387 | val = PIN_VREF100; |
| 388 | else if (pincap & AC_PINCAP_VREF_GRD) |
| 389 | val = PIN_VREFGRD; |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 390 | } |
| 391 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 392 | } |
| 393 | |
| 394 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 395 | * Append the given mixer and verb elements for the later use |
| 396 | * The mixer array is referred in build_controls(), and init_verbs are |
| 397 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 398 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 399 | 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] | 400 | { |
| 401 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 402 | return; |
| 403 | spec->mixers[spec->num_mixers++] = mix; |
| 404 | } |
| 405 | |
| 406 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) |
| 407 | { |
| 408 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) |
| 409 | return; |
| 410 | spec->init_verbs[spec->num_init_verbs++] = verb; |
| 411 | } |
| 412 | |
| 413 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 414 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 415 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 416 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 417 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 418 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 419 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 420 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 421 | { } |
| 422 | }; |
| 423 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 424 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 425 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 426 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 427 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 428 | { } |
| 429 | }; |
| 430 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 431 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 432 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 433 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 434 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 435 | { } |
| 436 | }; |
| 437 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 438 | /* |
| 439 | * Fix hardware PLL issue |
| 440 | * On some codecs, the analog PLL gating control must be off while |
| 441 | * the default value is 1. |
| 442 | */ |
| 443 | static void alc_fix_pll(struct hda_codec *codec) |
| 444 | { |
| 445 | struct alc_spec *spec = codec->spec; |
| 446 | unsigned int val; |
| 447 | |
| 448 | if (!spec->pll_nid) |
| 449 | return; |
| 450 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 451 | spec->pll_coef_idx); |
| 452 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 453 | AC_VERB_GET_PROC_COEF, 0); |
| 454 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 455 | spec->pll_coef_idx); |
| 456 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 457 | val & ~(1 << spec->pll_coef_bit)); |
| 458 | } |
| 459 | |
| 460 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 461 | unsigned int coef_idx, unsigned int coef_bit) |
| 462 | { |
| 463 | struct alc_spec *spec = codec->spec; |
| 464 | spec->pll_nid = nid; |
| 465 | spec->pll_coef_idx = coef_idx; |
| 466 | spec->pll_coef_bit = coef_bit; |
| 467 | alc_fix_pll(codec); |
| 468 | } |
| 469 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 470 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 471 | * Jack detections for HP auto-mute and mic-switch |
| 472 | */ |
| 473 | |
| 474 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 475 | 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] | 476 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 477 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 478 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 479 | for (i = 0; i < num_pins; i++) { |
| 480 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 481 | if (!nid) |
| 482 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 483 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 484 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 485 | return present; |
| 486 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 487 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 488 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 489 | 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] | 490 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 491 | { |
| 492 | struct alc_spec *spec = codec->spec; |
| 493 | unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 494 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 495 | int i; |
| 496 | |
| 497 | for (i = 0; i < num_pins; i++) { |
| 498 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 499 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 500 | if (!nid) |
| 501 | break; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 502 | switch (spec->automute_mode) { |
| 503 | case ALC_AUTOMUTE_PIN: |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 504 | /* don't reset VREF value in case it's controlling |
| 505 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 506 | */ |
| 507 | if (spec->keep_vref_in_automute) { |
| 508 | val = snd_hda_codec_read(codec, nid, 0, |
| 509 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 510 | val &= ~PIN_HP; |
| 511 | } else |
| 512 | val = 0; |
| 513 | val |= pin_bits; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 514 | snd_hda_codec_write(codec, nid, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 515 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 516 | val); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 517 | break; |
| 518 | case ALC_AUTOMUTE_AMP: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 519 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 520 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 521 | break; |
| 522 | case ALC_AUTOMUTE_MIXER: |
| 523 | nid = spec->automute_mixer_nid[i]; |
| 524 | if (!nid) |
| 525 | break; |
| 526 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 527 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 528 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 529 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 530 | break; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 531 | } |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 532 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 533 | } |
| 534 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 535 | /* Toggle outputs muting */ |
| 536 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 537 | { |
| 538 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 539 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 540 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 541 | /* Control HP pins/amps depending on master_mute state; |
| 542 | * in general, HP pins/amps control should be enabled in all cases, |
| 543 | * but currently set only for master_mute, just to be safe |
| 544 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 545 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 546 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 547 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 548 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 549 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 550 | on = 0; |
| 551 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 552 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 553 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 554 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 555 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 556 | |
| 557 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 558 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 559 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 560 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 561 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 562 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 563 | on = 0; |
| 564 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 565 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 566 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 567 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 568 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 569 | } |
| 570 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 571 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 572 | { |
| 573 | struct alc_spec *spec = codec->spec; |
| 574 | if (spec->automute_hook) |
| 575 | spec->automute_hook(codec); |
| 576 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 577 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 578 | } |
| 579 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 580 | /* standard HP-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 581 | static void alc_hp_automute(struct hda_codec *codec) |
| 582 | { |
| 583 | struct alc_spec *spec = codec->spec; |
| 584 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 585 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 586 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 587 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 588 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 589 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 590 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 591 | } |
| 592 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 593 | /* standard line-out-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 594 | static void alc_line_automute(struct hda_codec *codec) |
| 595 | { |
| 596 | struct alc_spec *spec = codec->spec; |
| 597 | |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 598 | /* check LO jack only when it's different from HP */ |
| 599 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 600 | return; |
| 601 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 602 | spec->line_jack_present = |
| 603 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 604 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 605 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 606 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 607 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 608 | } |
| 609 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 610 | #define get_connection_index(codec, mux, nid) \ |
| 611 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 612 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 613 | /* standard mic auto-switch helper */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 614 | static void alc_mic_automute(struct hda_codec *codec) |
| 615 | { |
| 616 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 617 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 618 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 619 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 620 | return; |
| 621 | if (snd_BUG_ON(!spec->adc_nids)) |
| 622 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 623 | 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] | 624 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 625 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 626 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 627 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 628 | else if (spec->dock_mic_idx >= 0 && |
| 629 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 630 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 631 | else |
| 632 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 633 | } |
| 634 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 635 | /* handle the specified unsol action (ALC_XXX_EVENT) */ |
| 636 | static void alc_exec_unsol_event(struct hda_codec *codec, int action) |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 637 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 638 | switch (action) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 639 | case ALC_HP_EVENT: |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 640 | alc_hp_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 641 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 642 | case ALC_FRONT_EVENT: |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 643 | alc_line_automute(codec); |
| 644 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 645 | case ALC_MIC_EVENT: |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 646 | alc_mic_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 647 | break; |
| 648 | } |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 649 | snd_hda_jack_report_sync(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 650 | } |
| 651 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 652 | /* unsolicited event for HP jack sensing */ |
| 653 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
| 654 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 655 | if (codec->vendor_id == 0x10ec0880) |
| 656 | res >>= 28; |
| 657 | else |
| 658 | res >>= 26; |
Takashi Iwai | a730979 | 2012-01-19 15:03:48 +0100 | [diff] [blame] | 659 | res = snd_hda_jack_get_action(codec, res); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 660 | alc_exec_unsol_event(codec, res); |
| 661 | } |
| 662 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 663 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 664 | static void alc_inithook(struct hda_codec *codec) |
| 665 | { |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 666 | alc_hp_automute(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 667 | alc_line_automute(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 668 | alc_mic_automute(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 669 | } |
| 670 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 671 | /* additional initialization for ALC888 variants */ |
| 672 | static void alc888_coef_init(struct hda_codec *codec) |
| 673 | { |
| 674 | unsigned int tmp; |
| 675 | |
| 676 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 677 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 678 | 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] | 679 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 680 | /* alc888S-VC */ |
| 681 | snd_hda_codec_read(codec, 0x20, 0, |
| 682 | AC_VERB_SET_PROC_COEF, 0x830); |
| 683 | else |
| 684 | /* alc888-VB */ |
| 685 | snd_hda_codec_read(codec, 0x20, 0, |
| 686 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 687 | } |
| 688 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 689 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 690 | static void alc889_coef_init(struct hda_codec *codec) |
| 691 | { |
| 692 | unsigned int tmp; |
| 693 | |
| 694 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 695 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 696 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 697 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 698 | } |
| 699 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 700 | /* turn on/off EAPD control (only if available) */ |
| 701 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 702 | { |
| 703 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 704 | return; |
| 705 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 706 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 707 | on ? 2 : 0); |
| 708 | } |
| 709 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 710 | /* turn on/off EAPD controls of the codec */ |
| 711 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 712 | { |
| 713 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 714 | static hda_nid_t pins[] = { |
| 715 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 716 | }; |
| 717 | hda_nid_t *p; |
| 718 | for (p = pins; *p; p++) |
| 719 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 720 | } |
| 721 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 722 | /* generic shutup callback; |
| 723 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 724 | */ |
| 725 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 726 | { |
| 727 | alc_auto_setup_eapd(codec, false); |
| 728 | msleep(200); |
| 729 | } |
| 730 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 731 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 732 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 733 | { |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 734 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 735 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 736 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 737 | switch (type) { |
| 738 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 739 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 740 | break; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 741 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 742 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 743 | break; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 744 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 745 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 746 | break; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 747 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 748 | switch (codec->vendor_id) { |
| 749 | case 0x10ec0260: |
| 750 | snd_hda_codec_write(codec, 0x1a, 0, |
| 751 | AC_VERB_SET_COEF_INDEX, 7); |
| 752 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 753 | AC_VERB_GET_PROC_COEF, 0); |
| 754 | snd_hda_codec_write(codec, 0x1a, 0, |
| 755 | AC_VERB_SET_COEF_INDEX, 7); |
| 756 | snd_hda_codec_write(codec, 0x1a, 0, |
| 757 | AC_VERB_SET_PROC_COEF, |
| 758 | tmp | 0x2010); |
| 759 | break; |
| 760 | case 0x10ec0262: |
| 761 | case 0x10ec0880: |
| 762 | case 0x10ec0882: |
| 763 | case 0x10ec0883: |
| 764 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 765 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 766 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 767 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 768 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 769 | case 0x10ec0888: |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 770 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 771 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 772 | #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] | 773 | case 0x10ec0267: |
| 774 | case 0x10ec0268: |
| 775 | snd_hda_codec_write(codec, 0x20, 0, |
| 776 | AC_VERB_SET_COEF_INDEX, 7); |
| 777 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 778 | AC_VERB_GET_PROC_COEF, 0); |
| 779 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 780 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 781 | snd_hda_codec_write(codec, 0x20, 0, |
| 782 | AC_VERB_SET_PROC_COEF, |
| 783 | tmp | 0x3000); |
| 784 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 785 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 786 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 787 | break; |
| 788 | } |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 789 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 790 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 791 | /* |
| 792 | * Auto-Mute mode mixer enum support |
| 793 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 794 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 795 | struct snd_ctl_elem_info *uinfo) |
| 796 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 797 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 798 | struct alc_spec *spec = codec->spec; |
| 799 | static const char * const texts2[] = { |
| 800 | "Disabled", "Enabled" |
| 801 | }; |
| 802 | static const char * const texts3[] = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 803 | "Disabled", "Speaker Only", "Line-Out+Speaker" |
| 804 | }; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 805 | const char * const *texts; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 806 | |
| 807 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 808 | uinfo->count = 1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 809 | if (spec->automute_speaker_possible && spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 810 | uinfo->value.enumerated.items = 3; |
| 811 | texts = texts3; |
| 812 | } else { |
| 813 | uinfo->value.enumerated.items = 2; |
| 814 | texts = texts2; |
| 815 | } |
| 816 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 817 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 818 | strcpy(uinfo->value.enumerated.name, |
| 819 | texts[uinfo->value.enumerated.item]); |
| 820 | return 0; |
| 821 | } |
| 822 | |
| 823 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 824 | struct snd_ctl_elem_value *ucontrol) |
| 825 | { |
| 826 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 827 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 828 | unsigned int val = 0; |
| 829 | if (spec->automute_speaker) |
| 830 | val++; |
| 831 | if (spec->automute_lo) |
| 832 | val++; |
| 833 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 834 | ucontrol->value.enumerated.item[0] = val; |
| 835 | return 0; |
| 836 | } |
| 837 | |
| 838 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 839 | struct snd_ctl_elem_value *ucontrol) |
| 840 | { |
| 841 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 842 | struct alc_spec *spec = codec->spec; |
| 843 | |
| 844 | switch (ucontrol->value.enumerated.item[0]) { |
| 845 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 846 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 847 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 848 | spec->automute_speaker = 0; |
| 849 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 850 | break; |
| 851 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 852 | if (spec->automute_speaker_possible) { |
| 853 | if (!spec->automute_lo && spec->automute_speaker) |
| 854 | return 0; |
| 855 | spec->automute_speaker = 1; |
| 856 | spec->automute_lo = 0; |
| 857 | } else if (spec->automute_lo_possible) { |
| 858 | if (spec->automute_lo) |
| 859 | return 0; |
| 860 | spec->automute_lo = 1; |
| 861 | } else |
| 862 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 863 | break; |
| 864 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 865 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 866 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 867 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 868 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 869 | spec->automute_speaker = 1; |
| 870 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 871 | break; |
| 872 | default: |
| 873 | return -EINVAL; |
| 874 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 875 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 876 | return 1; |
| 877 | } |
| 878 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 879 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 880 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 881 | .name = "Auto-Mute Mode", |
| 882 | .info = alc_automute_mode_info, |
| 883 | .get = alc_automute_mode_get, |
| 884 | .put = alc_automute_mode_put, |
| 885 | }; |
| 886 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 887 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
| 888 | { |
| 889 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 890 | return snd_array_new(&spec->kctls); |
| 891 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 892 | |
| 893 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 894 | { |
| 895 | struct alc_spec *spec = codec->spec; |
| 896 | struct snd_kcontrol_new *knew; |
| 897 | |
| 898 | knew = alc_kcontrol_new(spec); |
| 899 | if (!knew) |
| 900 | return -ENOMEM; |
| 901 | *knew = alc_automute_mode_enum; |
| 902 | knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); |
| 903 | if (!knew->name) |
| 904 | return -ENOMEM; |
| 905 | return 0; |
| 906 | } |
| 907 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 908 | /* |
| 909 | * Check the availability of HP/line-out auto-mute; |
| 910 | * Set up appropriately if really supported |
| 911 | */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 912 | static void alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 913 | { |
| 914 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 915 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 916 | int present = 0; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 917 | int i; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 918 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 919 | if (cfg->hp_pins[0]) |
| 920 | present++; |
| 921 | if (cfg->line_out_pins[0]) |
| 922 | present++; |
| 923 | if (cfg->speaker_pins[0]) |
| 924 | present++; |
| 925 | if (present < 2) /* need two different output types */ |
| 926 | return; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 927 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 928 | if (!cfg->speaker_pins[0] && |
| 929 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 930 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 931 | sizeof(cfg->speaker_pins)); |
| 932 | cfg->speaker_outs = cfg->line_outs; |
| 933 | } |
| 934 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 935 | if (!cfg->hp_pins[0] && |
| 936 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 937 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 938 | sizeof(cfg->hp_pins)); |
| 939 | cfg->hp_outs = cfg->line_outs; |
| 940 | } |
| 941 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 942 | spec->automute_mode = ALC_AUTOMUTE_PIN; |
| 943 | |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 944 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 945 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 946 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 947 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 948 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 949 | nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 950 | snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 951 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 952 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 953 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 954 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 955 | if (cfg->speaker_outs) |
| 956 | for (i = 0; i < cfg->line_outs; i++) { |
| 957 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 958 | if (!is_jack_detectable(codec, nid)) |
| 959 | continue; |
| 960 | snd_printdd("realtek: Enable Line-Out " |
| 961 | "auto-muting on NID 0x%x\n", nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 962 | snd_hda_jack_detect_enable(codec, nid, |
| 963 | ALC_FRONT_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 964 | spec->detect_lo = 1; |
| 965 | } |
| 966 | spec->automute_lo_possible = spec->detect_hp; |
| 967 | } |
| 968 | |
| 969 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 970 | (spec->detect_hp || spec->detect_lo); |
| 971 | |
| 972 | spec->automute_lo = spec->automute_lo_possible; |
| 973 | spec->automute_speaker = spec->automute_speaker_possible; |
| 974 | |
| 975 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 976 | /* create a control for automute mode */ |
| 977 | alc_add_automute_mode_enum(codec); |
| 978 | spec->unsol_event = alc_sku_unsol_event; |
| 979 | } |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 980 | } |
| 981 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 982 | /* 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] | 983 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 984 | { |
| 985 | int i; |
| 986 | for (i = 0; i < nums; i++) |
| 987 | if (list[i] == nid) |
| 988 | return i; |
| 989 | return -1; |
| 990 | } |
| 991 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 992 | /* check whether dynamic ADC-switching is available */ |
| 993 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 994 | { |
| 995 | struct alc_spec *spec = codec->spec; |
| 996 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 997 | int i, n, idx; |
| 998 | hda_nid_t cap, pin; |
| 999 | |
| 1000 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1001 | return false; |
| 1002 | |
| 1003 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1004 | cap = spec->private_capsrc_nids[n]; |
| 1005 | for (i = 0; i < imux->num_items; i++) { |
| 1006 | pin = spec->imux_pins[i]; |
| 1007 | if (!pin) |
| 1008 | return false; |
| 1009 | if (get_connection_index(codec, cap, pin) < 0) |
| 1010 | break; |
| 1011 | } |
| 1012 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1013 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | for (i = 0; i < imux->num_items; i++) { |
| 1017 | pin = spec->imux_pins[i]; |
| 1018 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1019 | cap = spec->private_capsrc_nids[n]; |
| 1020 | idx = get_connection_index(codec, cap, pin); |
| 1021 | if (idx >= 0) { |
| 1022 | imux->items[i].index = idx; |
| 1023 | spec->dyn_adc_idx[i] = n; |
| 1024 | break; |
| 1025 | } |
| 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1030 | spec->dyn_adc_switch = 1; |
| 1031 | return true; |
| 1032 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1033 | |
| 1034 | /* rebuild imux for matching with the given auto-mic pins (if not yet) */ |
| 1035 | static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec) |
| 1036 | { |
| 1037 | struct alc_spec *spec = codec->spec; |
| 1038 | struct hda_input_mux *imux; |
| 1039 | static char * const texts[3] = { |
| 1040 | "Mic", "Internal Mic", "Dock Mic" |
| 1041 | }; |
| 1042 | int i; |
| 1043 | |
| 1044 | if (!spec->auto_mic) |
| 1045 | return false; |
| 1046 | imux = &spec->private_imux[0]; |
| 1047 | if (spec->input_mux == imux) |
| 1048 | return true; |
| 1049 | spec->imux_pins[0] = spec->ext_mic_pin; |
| 1050 | spec->imux_pins[1] = spec->int_mic_pin; |
| 1051 | spec->imux_pins[2] = spec->dock_mic_pin; |
| 1052 | for (i = 0; i < 3; i++) { |
| 1053 | strcpy(imux->items[i].label, texts[i]); |
Takashi Iwai | 6759dc3 | 2011-11-23 07:38:59 +0100 | [diff] [blame] | 1054 | if (spec->imux_pins[i]) { |
| 1055 | hda_nid_t pin = spec->imux_pins[i]; |
| 1056 | int c; |
| 1057 | for (c = 0; c < spec->num_adc_nids; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1058 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | 6759dc3 | 2011-11-23 07:38:59 +0100 | [diff] [blame] | 1059 | int idx = get_connection_index(codec, cap, pin); |
| 1060 | if (idx >= 0) { |
| 1061 | imux->items[i].index = idx; |
| 1062 | break; |
| 1063 | } |
| 1064 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1065 | imux->num_items = i + 1; |
Takashi Iwai | 6759dc3 | 2011-11-23 07:38:59 +0100 | [diff] [blame] | 1066 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1067 | } |
| 1068 | spec->num_mux_defs = 1; |
| 1069 | spec->input_mux = imux; |
| 1070 | return true; |
| 1071 | } |
| 1072 | |
| 1073 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1074 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1075 | { |
| 1076 | struct alc_spec *spec = codec->spec; |
| 1077 | const struct hda_input_mux *imux; |
| 1078 | |
| 1079 | if (!spec->auto_mic) |
| 1080 | return false; |
| 1081 | if (spec->auto_mic_valid_imux) |
| 1082 | return true; /* already checked */ |
| 1083 | |
| 1084 | /* fill up imux indices */ |
| 1085 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1086 | spec->auto_mic = 0; |
| 1087 | return false; |
| 1088 | } |
| 1089 | |
| 1090 | imux = spec->input_mux; |
| 1091 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1092 | spec->imux_pins, imux->num_items); |
| 1093 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1094 | spec->imux_pins, imux->num_items); |
| 1095 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1096 | spec->imux_pins, imux->num_items); |
| 1097 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1098 | spec->auto_mic = 0; |
| 1099 | return false; /* no corresponding imux */ |
| 1100 | } |
| 1101 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1102 | snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1103 | if (spec->dock_mic_pin) |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1104 | snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, |
| 1105 | ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1106 | |
| 1107 | spec->auto_mic_valid_imux = 1; |
| 1108 | spec->auto_mic = 1; |
| 1109 | return true; |
| 1110 | } |
| 1111 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1112 | /* |
| 1113 | * Check the availability of auto-mic switch; |
| 1114 | * Set up if really supported |
| 1115 | */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1116 | static void alc_init_auto_mic(struct hda_codec *codec) |
| 1117 | { |
| 1118 | struct alc_spec *spec = codec->spec; |
| 1119 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1120 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1121 | int i; |
| 1122 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1123 | if (spec->shared_mic_hp) |
| 1124 | return; /* no auto-mic for the shared I/O */ |
| 1125 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1126 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1127 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1128 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1129 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1130 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1131 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1132 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1133 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1134 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1135 | if (fixed) |
| 1136 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1137 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1138 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1139 | fixed = nid; |
| 1140 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1141 | case INPUT_PIN_ATTR_UNUSED: |
| 1142 | return; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1143 | case INPUT_PIN_ATTR_DOCK: |
| 1144 | if (dock) |
| 1145 | return; /* already occupied */ |
| 1146 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 1147 | return; /* invalid type */ |
| 1148 | dock = nid; |
| 1149 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1150 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1151 | if (ext) |
| 1152 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1153 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1154 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1155 | ext = nid; |
| 1156 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1157 | } |
| 1158 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1159 | if (!ext && dock) { |
| 1160 | ext = dock; |
| 1161 | dock = 0; |
| 1162 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1163 | if (!ext || !fixed) |
| 1164 | return; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1165 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1166 | return; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1167 | if (dock && !is_jack_detectable(codec, dock)) |
| 1168 | return; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1169 | |
| 1170 | /* check imux indices */ |
| 1171 | spec->ext_mic_pin = ext; |
| 1172 | spec->int_mic_pin = fixed; |
| 1173 | spec->dock_mic_pin = dock; |
| 1174 | |
| 1175 | spec->auto_mic = 1; |
| 1176 | if (!alc_auto_mic_check_imux(codec)) |
| 1177 | return; |
| 1178 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1179 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1180 | ext, fixed, dock); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1181 | spec->unsol_event = alc_sku_unsol_event; |
| 1182 | } |
| 1183 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1184 | /* check the availabilities of auto-mute and auto-mic switches */ |
| 1185 | static void alc_auto_check_switches(struct hda_codec *codec) |
| 1186 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1187 | alc_init_automute(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1188 | alc_init_auto_mic(codec); |
| 1189 | } |
| 1190 | |
| 1191 | /* |
| 1192 | * Realtek SSID verification |
| 1193 | */ |
| 1194 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1195 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1196 | * the driver to ignore any present sku defines. |
| 1197 | */ |
| 1198 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1199 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1200 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1201 | { |
| 1202 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1203 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1204 | struct alc_spec *spec = codec->spec; |
| 1205 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1206 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1207 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1208 | if (spec->cdefine.fixup) { |
| 1209 | ass = spec->cdefine.sku_cfg; |
| 1210 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1211 | return -1; |
| 1212 | goto do_sku; |
| 1213 | } |
| 1214 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1215 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1216 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1217 | goto do_sku; |
| 1218 | |
| 1219 | nid = 0x1d; |
| 1220 | if (codec->vendor_id == 0x10ec0260) |
| 1221 | nid = 0x17; |
| 1222 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1223 | |
| 1224 | if (!(ass & 1)) { |
| 1225 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1226 | codec->chip_name, ass); |
| 1227 | return -1; |
| 1228 | } |
| 1229 | |
| 1230 | /* check sum */ |
| 1231 | tmp = 0; |
| 1232 | for (i = 1; i < 16; i++) { |
| 1233 | if ((ass >> i) & 1) |
| 1234 | tmp++; |
| 1235 | } |
| 1236 | if (((ass >> 16) & 0xf) != tmp) |
| 1237 | return -1; |
| 1238 | |
| 1239 | spec->cdefine.port_connectivity = ass >> 30; |
| 1240 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1241 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1242 | spec->cdefine.customization = ass >> 8; |
| 1243 | do_sku: |
| 1244 | spec->cdefine.sku_cfg = ass; |
| 1245 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1246 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1247 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1248 | spec->cdefine.override = ass & 0x1; |
| 1249 | |
| 1250 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1251 | nid, spec->cdefine.sku_cfg); |
| 1252 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1253 | spec->cdefine.port_connectivity); |
| 1254 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1255 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1256 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1257 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1258 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1259 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1260 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1261 | |
| 1262 | return 0; |
| 1263 | } |
| 1264 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1265 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1266 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1267 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1268 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1269 | } |
| 1270 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1271 | /* check subsystem ID and set up device-specific initialization; |
| 1272 | * return 1 if initialized, 0 if invalid SSID |
| 1273 | */ |
| 1274 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1275 | * 31 ~ 16 : Manufacture ID |
| 1276 | * 15 ~ 8 : SKU ID |
| 1277 | * 7 ~ 0 : Assembly ID |
| 1278 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1279 | */ |
| 1280 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1281 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1282 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1283 | { |
| 1284 | unsigned int ass, tmp, i; |
| 1285 | unsigned nid; |
| 1286 | struct alc_spec *spec = codec->spec; |
| 1287 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1288 | if (spec->cdefine.fixup) { |
| 1289 | ass = spec->cdefine.sku_cfg; |
| 1290 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1291 | return 0; |
| 1292 | goto do_sku; |
| 1293 | } |
| 1294 | |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1295 | ass = codec->subsystem_id & 0xffff; |
| 1296 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1297 | goto do_sku; |
| 1298 | |
| 1299 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1300 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1301 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1302 | * 29~21 : reserve |
| 1303 | * 20 : PCBEEP input |
| 1304 | * 19~16 : Check sum (15:1) |
| 1305 | * 15~1 : Custom |
| 1306 | * 0 : override |
| 1307 | */ |
| 1308 | nid = 0x1d; |
| 1309 | if (codec->vendor_id == 0x10ec0260) |
| 1310 | nid = 0x17; |
| 1311 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1312 | snd_printd("realtek: No valid SSID, " |
| 1313 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1314 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1315 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1316 | return 0; |
| 1317 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1318 | return 0; |
| 1319 | |
| 1320 | /* check sum */ |
| 1321 | tmp = 0; |
| 1322 | for (i = 1; i < 16; i++) { |
| 1323 | if ((ass >> i) & 1) |
| 1324 | tmp++; |
| 1325 | } |
| 1326 | if (((ass >> 16) & 0xf) != tmp) |
| 1327 | return 0; |
| 1328 | do_sku: |
| 1329 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1330 | ass & 0xffff, codec->vendor_id); |
| 1331 | /* |
| 1332 | * 0 : override |
| 1333 | * 1 : Swap Jack |
| 1334 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1335 | * 3~5 : External Amplifier control |
| 1336 | * 7~6 : Reserved |
| 1337 | */ |
| 1338 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1339 | switch (tmp) { |
| 1340 | case 1: |
| 1341 | spec->init_amp = ALC_INIT_GPIO1; |
| 1342 | break; |
| 1343 | case 3: |
| 1344 | spec->init_amp = ALC_INIT_GPIO2; |
| 1345 | break; |
| 1346 | case 7: |
| 1347 | spec->init_amp = ALC_INIT_GPIO3; |
| 1348 | break; |
| 1349 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1350 | default: |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1351 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1352 | break; |
| 1353 | } |
| 1354 | |
| 1355 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1356 | * when the external headphone out jack is plugged" |
| 1357 | */ |
| 1358 | if (!(ass & 0x8000)) |
| 1359 | return 1; |
| 1360 | /* |
| 1361 | * 10~8 : Jack location |
| 1362 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1363 | * 14~13: Resvered |
| 1364 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1365 | * when the external headphone out jack is plugged" |
| 1366 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1367 | if (!spec->autocfg.hp_pins[0] && |
| 1368 | !(spec->autocfg.line_out_pins[0] && |
| 1369 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1370 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1371 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1372 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1373 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1374 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1375 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1376 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1377 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1378 | else if (tmp == 3) |
| 1379 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1380 | else |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1381 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1382 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1383 | spec->autocfg.line_outs)) |
| 1384 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1385 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1386 | } |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1387 | return 1; |
| 1388 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1389 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1390 | /* Check the validity of ALC subsystem-id |
| 1391 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1392 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1393 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1394 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1395 | struct alc_spec *spec = codec->spec; |
| 1396 | snd_printd("realtek: " |
| 1397 | "Enable default setup for auto mode as fallback\n"); |
| 1398 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1399 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1400 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1401 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1402 | /* |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1403 | * Fix-up pin default configurations and add default verbs |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1404 | */ |
| 1405 | |
| 1406 | struct alc_pincfg { |
| 1407 | hda_nid_t nid; |
| 1408 | u32 val; |
| 1409 | }; |
| 1410 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1411 | struct alc_model_fixup { |
| 1412 | const int id; |
| 1413 | const char *name; |
| 1414 | }; |
| 1415 | |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1416 | struct alc_fixup { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1417 | int type; |
Takashi Iwai | 361fe6e | 2011-01-14 09:55:32 +0100 | [diff] [blame] | 1418 | bool chained; |
| 1419 | int chain_id; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1420 | union { |
| 1421 | unsigned int sku; |
| 1422 | const struct alc_pincfg *pins; |
| 1423 | const struct hda_verb *verbs; |
| 1424 | void (*func)(struct hda_codec *codec, |
| 1425 | const struct alc_fixup *fix, |
| 1426 | int action); |
| 1427 | } v; |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1428 | }; |
| 1429 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1430 | enum { |
| 1431 | ALC_FIXUP_INVALID, |
| 1432 | ALC_FIXUP_SKU, |
| 1433 | ALC_FIXUP_PINS, |
| 1434 | ALC_FIXUP_VERBS, |
| 1435 | ALC_FIXUP_FUNC, |
| 1436 | }; |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1437 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1438 | enum { |
| 1439 | ALC_FIXUP_ACT_PRE_PROBE, |
| 1440 | ALC_FIXUP_ACT_PROBE, |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1441 | ALC_FIXUP_ACT_INIT, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1442 | }; |
| 1443 | |
| 1444 | static void alc_apply_fixup(struct hda_codec *codec, int action) |
| 1445 | { |
| 1446 | struct alc_spec *spec = codec->spec; |
| 1447 | int id = spec->fixup_id; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1448 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1449 | const char *modelname = spec->fixup_name; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1450 | #endif |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1451 | int depth = 0; |
| 1452 | |
| 1453 | if (!spec->fixup_list) |
| 1454 | return; |
| 1455 | |
| 1456 | while (id >= 0) { |
| 1457 | const struct alc_fixup *fix = spec->fixup_list + id; |
| 1458 | const struct alc_pincfg *cfg; |
| 1459 | |
| 1460 | switch (fix->type) { |
| 1461 | case ALC_FIXUP_SKU: |
| 1462 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) |
Jesper Juhl | e53de8f | 2011-11-13 23:11:50 +0100 | [diff] [blame] | 1463 | break; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1464 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1465 | "Apply sku override for %s\n", |
| 1466 | codec->chip_name, modelname); |
| 1467 | spec->cdefine.sku_cfg = fix->v.sku; |
| 1468 | spec->cdefine.fixup = 1; |
| 1469 | break; |
| 1470 | case ALC_FIXUP_PINS: |
| 1471 | cfg = fix->v.pins; |
| 1472 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) |
| 1473 | break; |
| 1474 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1475 | "Apply pincfg for %s\n", |
| 1476 | codec->chip_name, modelname); |
| 1477 | for (; cfg->nid; cfg++) |
| 1478 | snd_hda_codec_set_pincfg(codec, cfg->nid, |
| 1479 | cfg->val); |
| 1480 | break; |
| 1481 | case ALC_FIXUP_VERBS: |
| 1482 | if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) |
| 1483 | break; |
| 1484 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1485 | "Apply fix-verbs for %s\n", |
| 1486 | codec->chip_name, modelname); |
| 1487 | add_verb(codec->spec, fix->v.verbs); |
| 1488 | break; |
| 1489 | case ALC_FIXUP_FUNC: |
| 1490 | if (!fix->v.func) |
| 1491 | break; |
| 1492 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1493 | "Apply fix-func for %s\n", |
| 1494 | codec->chip_name, modelname); |
| 1495 | fix->v.func(codec, fix, action); |
| 1496 | break; |
| 1497 | default: |
| 1498 | snd_printk(KERN_ERR "hda_codec: %s: " |
| 1499 | "Invalid fixup type %d\n", |
| 1500 | codec->chip_name, fix->type); |
| 1501 | break; |
| 1502 | } |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1503 | if (!fix->chained) |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1504 | break; |
| 1505 | if (++depth > 10) |
| 1506 | break; |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1507 | id = fix->chain_id; |
Takashi Iwai | 9d57883 | 2010-11-22 13:29:19 +0100 | [diff] [blame] | 1508 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1509 | } |
| 1510 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1511 | static void alc_pick_fixup(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1512 | const struct alc_model_fixup *models, |
| 1513 | const struct snd_pci_quirk *quirk, |
| 1514 | const struct alc_fixup *fixlist) |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1515 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1516 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1517 | const struct snd_pci_quirk *q; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1518 | int id = -1; |
| 1519 | const char *name = NULL; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1520 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1521 | if (codec->modelname && models) { |
| 1522 | while (models->name) { |
| 1523 | if (!strcmp(codec->modelname, models->name)) { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1524 | id = models->id; |
| 1525 | name = models->name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1526 | break; |
| 1527 | } |
| 1528 | models++; |
| 1529 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1530 | } |
| 1531 | if (id < 0) { |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1532 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| 1533 | if (q) { |
| 1534 | id = q->value; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1535 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1536 | name = q->name; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1537 | #endif |
| 1538 | } |
| 1539 | } |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1540 | if (id < 0) { |
| 1541 | for (q = quirk; q->subvendor; q++) { |
| 1542 | unsigned int vendorid = |
| 1543 | q->subdevice | (q->subvendor << 16); |
| 1544 | if (vendorid == codec->subsystem_id) { |
| 1545 | id = q->value; |
| 1546 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 1547 | name = q->name; |
| 1548 | #endif |
| 1549 | break; |
| 1550 | } |
| 1551 | } |
| 1552 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1553 | |
| 1554 | spec->fixup_id = id; |
| 1555 | if (id >= 0) { |
| 1556 | spec->fixup_list = fixlist; |
| 1557 | spec->fixup_name = name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1558 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1559 | } |
| 1560 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1561 | /* |
| 1562 | * COEF access helper functions |
| 1563 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1564 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1565 | unsigned int coef_idx) |
| 1566 | { |
| 1567 | unsigned int val; |
| 1568 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1569 | coef_idx); |
| 1570 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1571 | AC_VERB_GET_PROC_COEF, 0); |
| 1572 | return val; |
| 1573 | } |
| 1574 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1575 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1576 | unsigned int coef_val) |
| 1577 | { |
| 1578 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1579 | coef_idx); |
| 1580 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1581 | coef_val); |
| 1582 | } |
| 1583 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1584 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1585 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1586 | { |
| 1587 | struct alc_spec *spec = codec->spec; |
| 1588 | if (!spec->coef0) |
| 1589 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1590 | return spec->coef0; |
| 1591 | } |
| 1592 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1593 | /* |
| 1594 | * Digital I/O handling |
| 1595 | */ |
| 1596 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1597 | /* set right pin controls for digital I/O */ |
| 1598 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1599 | { |
| 1600 | struct alc_spec *spec = codec->spec; |
| 1601 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1602 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1603 | |
| 1604 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1605 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1606 | if (!pin) |
| 1607 | continue; |
| 1608 | snd_hda_codec_write(codec, pin, 0, |
| 1609 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
| 1610 | if (!i) |
| 1611 | dac = spec->multiout.dig_out_nid; |
| 1612 | else |
| 1613 | dac = spec->slave_dig_outs[i - 1]; |
| 1614 | if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) |
| 1615 | continue; |
| 1616 | snd_hda_codec_write(codec, dac, 0, |
| 1617 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1618 | AMP_OUT_UNMUTE); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1619 | } |
| 1620 | pin = spec->autocfg.dig_in_pin; |
| 1621 | if (pin) |
| 1622 | snd_hda_codec_write(codec, pin, 0, |
| 1623 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1624 | PIN_IN); |
| 1625 | } |
| 1626 | |
| 1627 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1628 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1629 | { |
| 1630 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1631 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1632 | hda_nid_t dig_nid; |
| 1633 | |
| 1634 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1635 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1636 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1637 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1638 | err = snd_hda_get_connections(codec, |
| 1639 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1640 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1641 | if (err <= 0) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1642 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1643 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1644 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1645 | spec->multiout.dig_out_nid = dig_nid; |
| 1646 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1647 | } else { |
| 1648 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1649 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1650 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1651 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1652 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1653 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1654 | } |
| 1655 | |
| 1656 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1657 | dig_nid = codec->start_nid; |
| 1658 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1659 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1660 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1661 | continue; |
| 1662 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1663 | continue; |
| 1664 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1665 | continue; |
| 1666 | err = get_connection_index(codec, dig_nid, |
| 1667 | spec->autocfg.dig_in_pin); |
| 1668 | if (err >= 0) { |
| 1669 | spec->dig_in_nid = dig_nid; |
| 1670 | break; |
| 1671 | } |
| 1672 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1673 | } |
| 1674 | } |
| 1675 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1676 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1677 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1678 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1679 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1680 | struct snd_ctl_elem_info *uinfo) |
| 1681 | { |
| 1682 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1683 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1684 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1685 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1686 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1687 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1688 | if (spec->vol_in_capsrc) |
| 1689 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1690 | else |
| 1691 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1692 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1693 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1694 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1695 | return err; |
| 1696 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1697 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1698 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1699 | unsigned int size, unsigned int __user *tlv) |
| 1700 | { |
| 1701 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1702 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1703 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1704 | int err; |
| 1705 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1706 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1707 | if (spec->vol_in_capsrc) |
| 1708 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1709 | else |
| 1710 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1711 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1712 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1713 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1714 | return err; |
| 1715 | } |
| 1716 | |
| 1717 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1718 | struct snd_ctl_elem_value *ucontrol); |
| 1719 | |
| 1720 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1721 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1722 | getput_call_t func, bool check_adc_switch) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1723 | { |
| 1724 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1725 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1726 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1727 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1728 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1729 | if (check_adc_switch && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1730 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1731 | kcontrol->private_value = |
| 1732 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1733 | 3, 0, HDA_INPUT); |
| 1734 | err = func(kcontrol, ucontrol); |
| 1735 | if (err < 0) |
| 1736 | goto error; |
| 1737 | } |
| 1738 | } else { |
| 1739 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1740 | if (spec->vol_in_capsrc) |
| 1741 | kcontrol->private_value = |
| 1742 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1743 | 3, 0, HDA_OUTPUT); |
| 1744 | else |
| 1745 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1746 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1747 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1748 | err = func(kcontrol, ucontrol); |
| 1749 | } |
| 1750 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1751 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1752 | return err; |
| 1753 | } |
| 1754 | |
| 1755 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1756 | struct snd_ctl_elem_value *ucontrol) |
| 1757 | { |
| 1758 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1759 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1760 | } |
| 1761 | |
| 1762 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1763 | struct snd_ctl_elem_value *ucontrol) |
| 1764 | { |
| 1765 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1766 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | /* capture mixer elements */ |
| 1770 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1771 | |
| 1772 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1773 | struct snd_ctl_elem_value *ucontrol) |
| 1774 | { |
| 1775 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1776 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1777 | } |
| 1778 | |
| 1779 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1780 | struct snd_ctl_elem_value *ucontrol) |
| 1781 | { |
| 1782 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1783 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1784 | } |
| 1785 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1786 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1787 | { \ |
| 1788 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1789 | .name = "Capture Switch", \ |
| 1790 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1791 | .count = num, \ |
| 1792 | .info = alc_cap_sw_info, \ |
| 1793 | .get = alc_cap_sw_get, \ |
| 1794 | .put = alc_cap_sw_put, \ |
| 1795 | }, \ |
| 1796 | { \ |
| 1797 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1798 | .name = "Capture Volume", \ |
| 1799 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1800 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1801 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1802 | .count = num, \ |
| 1803 | .info = alc_cap_vol_info, \ |
| 1804 | .get = alc_cap_vol_get, \ |
| 1805 | .put = alc_cap_vol_put, \ |
| 1806 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1807 | } |
| 1808 | |
| 1809 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1810 | { \ |
| 1811 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1812 | /* .name = "Capture Source", */ \ |
| 1813 | .name = "Input Source", \ |
| 1814 | .count = num, \ |
| 1815 | .info = alc_mux_enum_info, \ |
| 1816 | .get = alc_mux_enum_get, \ |
| 1817 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1818 | } |
| 1819 | |
| 1820 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1821 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1822 | _DEFINE_CAPMIX(num), \ |
| 1823 | _DEFINE_CAPSRC(num), \ |
| 1824 | { } /* end */ \ |
| 1825 | } |
| 1826 | |
| 1827 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1828 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1829 | _DEFINE_CAPMIX(num), \ |
| 1830 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1831 | } |
| 1832 | |
| 1833 | /* up to three ADCs */ |
| 1834 | DEFINE_CAPMIX(1); |
| 1835 | DEFINE_CAPMIX(2); |
| 1836 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1837 | DEFINE_CAPMIX_NOSRC(1); |
| 1838 | DEFINE_CAPMIX_NOSRC(2); |
| 1839 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1840 | |
| 1841 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1842 | * virtual master controls |
| 1843 | */ |
| 1844 | |
| 1845 | /* |
| 1846 | * slave controls for virtual master |
| 1847 | */ |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1848 | static const char * const alc_slave_vols[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1849 | "Front Playback Volume", |
| 1850 | "Surround Playback Volume", |
| 1851 | "Center Playback Volume", |
| 1852 | "LFE Playback Volume", |
| 1853 | "Side Playback Volume", |
| 1854 | "Headphone Playback Volume", |
| 1855 | "Speaker Playback Volume", |
| 1856 | "Mono Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1857 | "Line-Out Playback Volume", |
Takashi Iwai | b544d1e | 2012-02-03 11:56:35 +0100 | [diff] [blame] | 1858 | "CLFE Playback Volume", |
| 1859 | "Bass Speaker Playback Volume", |
Takashi Iwai | 3fe45ae | 2011-08-18 15:13:17 +0200 | [diff] [blame] | 1860 | "PCM Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1861 | NULL, |
| 1862 | }; |
| 1863 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1864 | static const char * const alc_slave_sws[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1865 | "Front Playback Switch", |
| 1866 | "Surround Playback Switch", |
| 1867 | "Center Playback Switch", |
| 1868 | "LFE Playback Switch", |
| 1869 | "Side Playback Switch", |
| 1870 | "Headphone Playback Switch", |
| 1871 | "Speaker Playback Switch", |
| 1872 | "Mono Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1873 | "IEC958 Playback Switch", |
Takashi Iwai | 23033b2 | 2009-12-08 12:36:52 +0100 | [diff] [blame] | 1874 | "Line-Out Playback Switch", |
Takashi Iwai | b544d1e | 2012-02-03 11:56:35 +0100 | [diff] [blame] | 1875 | "CLFE Playback Switch", |
| 1876 | "Bass Speaker Playback Switch", |
Takashi Iwai | 3fe45ae | 2011-08-18 15:13:17 +0200 | [diff] [blame] | 1877 | "PCM Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1878 | NULL, |
| 1879 | }; |
| 1880 | |
| 1881 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1882 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1883 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1884 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1885 | #define NID_MAPPING (-1) |
| 1886 | |
| 1887 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1888 | #define SUBDEV_HP_ (1 << 6) |
| 1889 | #define SUBDEV_LINE_ (2 << 6) |
| 1890 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1891 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1892 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1893 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1894 | static void alc_free_kctls(struct hda_codec *codec); |
| 1895 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1896 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1897 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1898 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1899 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1900 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1901 | { } /* end */ |
| 1902 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1903 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1904 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1905 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | { |
| 1907 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1908 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1909 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1910 | int i, j, err; |
| 1911 | unsigned int u; |
| 1912 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | |
| 1914 | for (i = 0; i < spec->num_mixers; i++) { |
| 1915 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1916 | if (err < 0) |
| 1917 | return err; |
| 1918 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1919 | if (spec->cap_mixer) { |
| 1920 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1921 | if (err < 0) |
| 1922 | return err; |
| 1923 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1924 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1925 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1926 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1927 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1928 | if (err < 0) |
| 1929 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1930 | if (!spec->no_analog) { |
| 1931 | err = snd_hda_create_spdif_share_sw(codec, |
| 1932 | &spec->multiout); |
| 1933 | if (err < 0) |
| 1934 | return err; |
| 1935 | spec->multiout.share_spdif = 1; |
| 1936 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1937 | } |
| 1938 | if (spec->dig_in_nid) { |
| 1939 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1940 | if (err < 0) |
| 1941 | return err; |
| 1942 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1943 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1944 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1945 | /* create beep controls if needed */ |
| 1946 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1947 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1948 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1949 | struct snd_kcontrol *kctl; |
| 1950 | kctl = snd_ctl_new1(knew, codec); |
| 1951 | if (!kctl) |
| 1952 | return -ENOMEM; |
| 1953 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1954 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1955 | if (err < 0) |
| 1956 | return err; |
| 1957 | } |
| 1958 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1959 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1960 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1961 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1962 | if (!spec->no_analog && |
| 1963 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1964 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1965 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1966 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1967 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1968 | vmaster_tlv, alc_slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1969 | if (err < 0) |
| 1970 | return err; |
| 1971 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1972 | if (!spec->no_analog && |
| 1973 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1974 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1975 | NULL, alc_slave_sws); |
| 1976 | if (err < 0) |
| 1977 | return err; |
| 1978 | } |
| 1979 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1980 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1981 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1982 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1983 | if (!kctl) |
| 1984 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1985 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1986 | err = snd_hda_add_nid(codec, kctl, i, |
| 1987 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1988 | if (err < 0) |
| 1989 | return err; |
| 1990 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1991 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1992 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1993 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1994 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1995 | if (kname && strcmp(knew->name, kname) == 0) |
| 1996 | continue; |
| 1997 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1998 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1999 | err = snd_hda_add_nid(codec, kctl, i, |
| 2000 | spec->adc_nids[i]); |
| 2001 | if (err < 0) |
| 2002 | return err; |
| 2003 | } |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | /* other nid->control mapping */ |
| 2008 | for (i = 0; i < spec->num_mixers; i++) { |
| 2009 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 2010 | if (knew->iface != NID_MAPPING) |
| 2011 | continue; |
| 2012 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 2013 | if (kctl == NULL) |
| 2014 | continue; |
| 2015 | u = knew->subdevice; |
| 2016 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2017 | nid = u & 0x3f; |
| 2018 | if (nid == 0) |
| 2019 | continue; |
| 2020 | switch (u & 0xc0) { |
| 2021 | case SUBDEV_SPEAKER_: |
| 2022 | nid = spec->autocfg.speaker_pins[nid]; |
| 2023 | break; |
| 2024 | case SUBDEV_LINE_: |
| 2025 | nid = spec->autocfg.line_out_pins[nid]; |
| 2026 | break; |
| 2027 | case SUBDEV_HP_: |
| 2028 | nid = spec->autocfg.hp_pins[nid]; |
| 2029 | break; |
| 2030 | default: |
| 2031 | continue; |
| 2032 | } |
| 2033 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2034 | if (err < 0) |
| 2035 | return err; |
| 2036 | } |
| 2037 | u = knew->private_value; |
| 2038 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2039 | nid = u & 0xff; |
| 2040 | if (nid == 0) |
| 2041 | continue; |
| 2042 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2043 | if (err < 0) |
| 2044 | return err; |
| 2045 | } |
| 2046 | } |
| 2047 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 2048 | |
| 2049 | alc_free_kctls(codec); /* no longer needed */ |
| 2050 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 2051 | return 0; |
| 2052 | } |
| 2053 | |
| 2054 | static int alc_build_controls(struct hda_codec *codec) |
| 2055 | { |
| 2056 | struct alc_spec *spec = codec->spec; |
| 2057 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2058 | if (err < 0) |
| 2059 | return err; |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 2060 | return snd_hda_jack_add_kctls(codec, &spec->autocfg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | } |
| 2062 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2063 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2065 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2066 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2067 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2068 | static void alc_init_special_input_src(struct hda_codec *codec); |
| 2069 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | static int alc_init(struct hda_codec *codec) |
| 2071 | { |
| 2072 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2073 | unsigned int i; |
| 2074 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2075 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba34 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2076 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2077 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2078 | for (i = 0; i < spec->num_init_verbs; i++) |
| 2079 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2080 | alc_init_special_input_src(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2081 | |
| 2082 | if (spec->init_hook) |
| 2083 | spec->init_hook(codec); |
| 2084 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2085 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2086 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2087 | snd_hda_jack_report_sync(codec); |
| 2088 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2089 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | return 0; |
| 2091 | } |
| 2092 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2093 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2094 | { |
| 2095 | struct alc_spec *spec = codec->spec; |
| 2096 | |
| 2097 | if (spec->unsol_event) |
| 2098 | spec->unsol_event(codec, res); |
| 2099 | } |
| 2100 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2101 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2102 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2103 | { |
| 2104 | struct alc_spec *spec = codec->spec; |
| 2105 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2106 | } |
| 2107 | #endif |
| 2108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | /* |
| 2110 | * Analog playback callbacks |
| 2111 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2112 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2114 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | { |
| 2116 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2117 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2118 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2119 | } |
| 2120 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2121 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | struct hda_codec *codec, |
| 2123 | unsigned int stream_tag, |
| 2124 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2125 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | { |
| 2127 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2128 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2129 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | } |
| 2131 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2132 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2134 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2135 | { |
| 2136 | struct alc_spec *spec = codec->spec; |
| 2137 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2138 | } |
| 2139 | |
| 2140 | /* |
| 2141 | * Digital out |
| 2142 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2143 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2145 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2146 | { |
| 2147 | struct alc_spec *spec = codec->spec; |
| 2148 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2149 | } |
| 2150 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2151 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2152 | struct hda_codec *codec, |
| 2153 | unsigned int stream_tag, |
| 2154 | unsigned int format, |
| 2155 | struct snd_pcm_substream *substream) |
| 2156 | { |
| 2157 | struct alc_spec *spec = codec->spec; |
| 2158 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2159 | stream_tag, format, substream); |
| 2160 | } |
| 2161 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2162 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2163 | struct hda_codec *codec, |
| 2164 | struct snd_pcm_substream *substream) |
| 2165 | { |
| 2166 | struct alc_spec *spec = codec->spec; |
| 2167 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2168 | } |
| 2169 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2170 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2172 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2173 | { |
| 2174 | struct alc_spec *spec = codec->spec; |
| 2175 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2176 | } |
| 2177 | |
| 2178 | /* |
| 2179 | * Analog capture |
| 2180 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2181 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | struct hda_codec *codec, |
| 2183 | unsigned int stream_tag, |
| 2184 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2185 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | { |
| 2187 | struct alc_spec *spec = codec->spec; |
| 2188 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2189 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2190 | stream_tag, 0, format); |
| 2191 | return 0; |
| 2192 | } |
| 2193 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2194 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2195 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2196 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | { |
| 2198 | struct alc_spec *spec = codec->spec; |
| 2199 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2200 | snd_hda_codec_cleanup_stream(codec, |
| 2201 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2202 | return 0; |
| 2203 | } |
| 2204 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2205 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2206 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2207 | struct hda_codec *codec, |
| 2208 | unsigned int stream_tag, |
| 2209 | unsigned int format, |
| 2210 | struct snd_pcm_substream *substream) |
| 2211 | { |
| 2212 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2213 | 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] | 2214 | spec->cur_adc_stream_tag = stream_tag; |
| 2215 | spec->cur_adc_format = format; |
| 2216 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2217 | return 0; |
| 2218 | } |
| 2219 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2220 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2221 | struct hda_codec *codec, |
| 2222 | struct snd_pcm_substream *substream) |
| 2223 | { |
| 2224 | struct alc_spec *spec = codec->spec; |
| 2225 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2226 | spec->cur_adc = 0; |
| 2227 | return 0; |
| 2228 | } |
| 2229 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2230 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2231 | .substreams = 1, |
| 2232 | .channels_min = 2, |
| 2233 | .channels_max = 2, |
| 2234 | .nid = 0, /* fill later */ |
| 2235 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2236 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2237 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2238 | }, |
| 2239 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | |
| 2241 | /* |
| 2242 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2243 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | .substreams = 1, |
| 2245 | .channels_min = 2, |
| 2246 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2247 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2249 | .open = alc_playback_pcm_open, |
| 2250 | .prepare = alc_playback_pcm_prepare, |
| 2251 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | }, |
| 2253 | }; |
| 2254 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2255 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2256 | .substreams = 1, |
| 2257 | .channels_min = 2, |
| 2258 | .channels_max = 2, |
| 2259 | /* NID is set in alc_build_pcms */ |
| 2260 | }; |
| 2261 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2262 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2263 | .substreams = 1, |
| 2264 | .channels_min = 2, |
| 2265 | .channels_max = 2, |
| 2266 | /* NID is set in alc_build_pcms */ |
| 2267 | }; |
| 2268 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2269 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2270 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | .channels_min = 2, |
| 2272 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2273 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2275 | .prepare = alc_alt_capture_pcm_prepare, |
| 2276 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | }, |
| 2278 | }; |
| 2279 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2280 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | .substreams = 1, |
| 2282 | .channels_min = 2, |
| 2283 | .channels_max = 2, |
| 2284 | /* NID is set in alc_build_pcms */ |
| 2285 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2286 | .open = alc_dig_playback_pcm_open, |
| 2287 | .close = alc_dig_playback_pcm_close, |
| 2288 | .prepare = alc_dig_playback_pcm_prepare, |
| 2289 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | }, |
| 2291 | }; |
| 2292 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2293 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | .substreams = 1, |
| 2295 | .channels_min = 2, |
| 2296 | .channels_max = 2, |
| 2297 | /* NID is set in alc_build_pcms */ |
| 2298 | }; |
| 2299 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2300 | /* 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] | 2301 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2302 | .substreams = 0, |
| 2303 | .channels_min = 0, |
| 2304 | .channels_max = 0, |
| 2305 | }; |
| 2306 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | static int alc_build_pcms(struct hda_codec *codec) |
| 2308 | { |
| 2309 | struct alc_spec *spec = codec->spec; |
| 2310 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2311 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2312 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | int i; |
| 2314 | |
| 2315 | codec->num_pcms = 1; |
| 2316 | codec->pcm_info = info; |
| 2317 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2318 | if (spec->no_analog) |
| 2319 | goto skip_analog; |
| 2320 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2321 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2322 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2324 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame^] | 2325 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2326 | p = spec->stream_analog_playback; |
| 2327 | if (!p) |
| 2328 | p = &alc_pcm_analog_playback; |
| 2329 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2330 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 2331 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2332 | if (spec->adc_nids) { |
| 2333 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2334 | if (!p) { |
| 2335 | if (spec->dyn_adc_switch) |
| 2336 | p = &dyn_adc_pcm_analog_capture; |
| 2337 | else |
| 2338 | p = &alc_pcm_analog_capture; |
| 2339 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2340 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2341 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2342 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2344 | if (spec->channel_mode) { |
| 2345 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2346 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2347 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2348 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2349 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | } |
| 2351 | } |
| 2352 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2353 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2354 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2356 | snprintf(spec->stream_name_digital, |
| 2357 | sizeof(spec->stream_name_digital), |
| 2358 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2359 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2360 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2361 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2363 | if (spec->dig_out_type) |
| 2364 | info->pcm_type = spec->dig_out_type; |
| 2365 | else |
| 2366 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2367 | if (spec->multiout.dig_out_nid) { |
| 2368 | p = spec->stream_digital_playback; |
| 2369 | if (!p) |
| 2370 | p = &alc_pcm_digital_playback; |
| 2371 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2372 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2373 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2374 | if (spec->dig_in_nid) { |
| 2375 | p = spec->stream_digital_capture; |
| 2376 | if (!p) |
| 2377 | p = &alc_pcm_digital_capture; |
| 2378 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2379 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2380 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2381 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2382 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | } |
| 2384 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2385 | if (spec->no_analog) |
| 2386 | return 0; |
| 2387 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2388 | /* If the use of more than one ADC is requested for the current |
| 2389 | * model, configure a second analog capture-only PCM. |
| 2390 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2391 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2392 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2393 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2394 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2395 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2396 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2397 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2398 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2399 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2400 | p = spec->stream_analog_alt_playback; |
| 2401 | if (!p) |
| 2402 | p = &alc_pcm_analog_alt_playback; |
| 2403 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2404 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2405 | spec->alt_dac_nid; |
| 2406 | } else { |
| 2407 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2408 | alc_pcm_null_stream; |
| 2409 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2410 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2411 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2412 | p = spec->stream_analog_alt_capture; |
| 2413 | if (!p) |
| 2414 | p = &alc_pcm_analog_alt_capture; |
| 2415 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2416 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2417 | spec->adc_nids[1]; |
| 2418 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2419 | spec->num_adc_nids - 1; |
| 2420 | } else { |
| 2421 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2422 | alc_pcm_null_stream; |
| 2423 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2424 | } |
| 2425 | } |
| 2426 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2427 | return 0; |
| 2428 | } |
| 2429 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2430 | static inline void alc_shutup(struct hda_codec *codec) |
| 2431 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2432 | struct alc_spec *spec = codec->spec; |
| 2433 | |
| 2434 | if (spec && spec->shutup) |
| 2435 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2436 | snd_hda_shutup_pins(codec); |
| 2437 | } |
| 2438 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2439 | static void alc_free_kctls(struct hda_codec *codec) |
| 2440 | { |
| 2441 | struct alc_spec *spec = codec->spec; |
| 2442 | |
| 2443 | if (spec->kctls.list) { |
| 2444 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2445 | int i; |
| 2446 | for (i = 0; i < spec->kctls.used; i++) |
| 2447 | kfree(kctl[i].name); |
| 2448 | } |
| 2449 | snd_array_free(&spec->kctls); |
| 2450 | } |
| 2451 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2452 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2453 | { |
| 2454 | struct alc_spec *spec = codec->spec; |
| 2455 | if (spec->bind_ctls.list) { |
| 2456 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2457 | int i; |
| 2458 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2459 | kfree(ctl[i]); |
| 2460 | } |
| 2461 | snd_array_free(&spec->bind_ctls); |
| 2462 | } |
| 2463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2464 | static void alc_free(struct hda_codec *codec) |
| 2465 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2466 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2467 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2468 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2469 | return; |
| 2470 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2471 | alc_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2472 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2473 | alc_free_bind_ctls(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2474 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2475 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | } |
| 2477 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2478 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2479 | static void alc_power_eapd(struct hda_codec *codec) |
| 2480 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2481 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2482 | } |
| 2483 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2484 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
| 2485 | { |
| 2486 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2487 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2488 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2489 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2490 | return 0; |
| 2491 | } |
| 2492 | #endif |
| 2493 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2494 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2495 | static int alc_resume(struct hda_codec *codec) |
| 2496 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2497 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2498 | codec->patch_ops.init(codec); |
| 2499 | snd_hda_codec_resume_amp(codec); |
| 2500 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2501 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2502 | return 0; |
| 2503 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2504 | #endif |
| 2505 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2506 | /* |
| 2507 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2508 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | .build_controls = alc_build_controls, |
| 2510 | .build_pcms = alc_build_pcms, |
| 2511 | .init = alc_init, |
| 2512 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2513 | .unsol_event = alc_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2514 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2515 | .resume = alc_resume, |
| 2516 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2517 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2518 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2519 | .check_power_status = alc_check_power_status, |
| 2520 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2521 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | }; |
| 2523 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2524 | /* replace the codec chip_name with the given string */ |
| 2525 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2526 | { |
| 2527 | kfree(codec->chip_name); |
| 2528 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2529 | if (!codec->chip_name) { |
| 2530 | alc_free(codec); |
| 2531 | return -ENOMEM; |
| 2532 | } |
| 2533 | return 0; |
| 2534 | } |
| 2535 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2536 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2537 | * Rename codecs appropriately from COEF value |
| 2538 | */ |
| 2539 | struct alc_codec_rename_table { |
| 2540 | unsigned int vendor_id; |
| 2541 | unsigned short coef_mask; |
| 2542 | unsigned short coef_bits; |
| 2543 | const char *name; |
| 2544 | }; |
| 2545 | |
| 2546 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2547 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2548 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2549 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2550 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2551 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2552 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2553 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
| 2554 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2555 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2556 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2557 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2558 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2559 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2560 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2561 | { } /* terminator */ |
| 2562 | }; |
| 2563 | |
| 2564 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2565 | { |
| 2566 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2567 | |
| 2568 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2569 | if (p->vendor_id != codec->vendor_id) |
| 2570 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2571 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2572 | return alc_codec_rename(codec, p->name); |
| 2573 | } |
| 2574 | return 0; |
| 2575 | } |
| 2576 | |
| 2577 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2578 | * Automatic parse of I/O pins from the BIOS configuration |
| 2579 | */ |
| 2580 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2581 | enum { |
| 2582 | ALC_CTL_WIDGET_VOL, |
| 2583 | ALC_CTL_WIDGET_MUTE, |
| 2584 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2585 | ALC_CTL_BIND_VOL, |
| 2586 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2587 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2588 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2589 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2590 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2591 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2592 | HDA_BIND_VOL(NULL, 0), |
| 2593 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2594 | }; |
| 2595 | |
| 2596 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2597 | 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] | 2598 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2599 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2600 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2601 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2602 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2603 | if (!knew) |
| 2604 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2605 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2606 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2607 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2608 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2609 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2610 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2611 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2612 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2613 | return 0; |
| 2614 | } |
| 2615 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2616 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2617 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2618 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2619 | { |
| 2620 | char name[32]; |
| 2621 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2622 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2623 | } |
| 2624 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2625 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2626 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2627 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2628 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2629 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2630 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2631 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2632 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2633 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2634 | static const char * const channel_name[4] = { |
| 2635 | "Front", "Surround", "CLFE", "Side" |
| 2636 | }; |
| 2637 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2638 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2639 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2640 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2641 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2642 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2643 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2644 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2645 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2646 | return "Master"; |
| 2647 | |
| 2648 | switch (cfg->line_out_type) { |
| 2649 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2650 | if (cfg->line_outs == 1) |
| 2651 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2652 | if (cfg->line_outs == 2) |
| 2653 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2654 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2655 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2656 | /* for multi-io case, only the primary out */ |
| 2657 | if (ch && spec->multi_ios) |
| 2658 | break; |
| 2659 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2660 | return "Headphone"; |
| 2661 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2662 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2663 | return "PCM"; |
| 2664 | break; |
| 2665 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2666 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2667 | return "PCM"; |
| 2668 | |
| 2669 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2670 | } |
| 2671 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2672 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2673 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2674 | const char *ctlname, int ctlidx, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2675 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2676 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2677 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2678 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2679 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2680 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2681 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2682 | return err; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2683 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2684 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2685 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2686 | return err; |
| 2687 | return 0; |
| 2688 | } |
| 2689 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2690 | 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] | 2691 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2692 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2693 | return (pincap & AC_PINCAP_IN) != 0; |
| 2694 | } |
| 2695 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2696 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2697 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2698 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2699 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2700 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2701 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2702 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2703 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2704 | int i, nums = 0; |
| 2705 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2706 | if (spec->shared_mic_hp) |
| 2707 | max_nums = 1; /* no multi streams with the shared HP/mic */ |
| 2708 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2709 | nid = codec->start_nid; |
| 2710 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2711 | hda_nid_t src; |
| 2712 | const hda_nid_t *list; |
| 2713 | unsigned int caps = get_wcaps(codec, nid); |
| 2714 | int type = get_wcaps_type(caps); |
| 2715 | |
| 2716 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2717 | continue; |
| 2718 | adc_nids[nums] = nid; |
| 2719 | cap_nids[nums] = nid; |
| 2720 | src = nid; |
| 2721 | for (;;) { |
| 2722 | int n; |
| 2723 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2724 | if (type == AC_WID_PIN) |
| 2725 | break; |
| 2726 | if (type == AC_WID_AUD_SEL) { |
| 2727 | cap_nids[nums] = src; |
| 2728 | break; |
| 2729 | } |
| 2730 | n = snd_hda_get_conn_list(codec, src, &list); |
| 2731 | if (n > 1) { |
| 2732 | cap_nids[nums] = src; |
| 2733 | break; |
| 2734 | } else if (n != 1) |
| 2735 | break; |
| 2736 | src = *list; |
| 2737 | } |
| 2738 | if (++nums >= max_nums) |
| 2739 | break; |
| 2740 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2741 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2742 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2743 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2744 | return nums; |
| 2745 | } |
| 2746 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2747 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2748 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2749 | { |
| 2750 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2751 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2752 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2753 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2754 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2755 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2756 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2757 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2758 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2759 | if (num_adcs < 0) |
| 2760 | return 0; |
| 2761 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2762 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2763 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2764 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2765 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2766 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2767 | if (!alc_is_input_pin(codec, pin)) |
| 2768 | continue; |
| 2769 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2770 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2771 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2772 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2773 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2774 | type_idx++; |
| 2775 | else |
| 2776 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2777 | prev_label = label; |
| 2778 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2779 | if (mixer) { |
| 2780 | idx = get_connection_index(codec, mixer, pin); |
| 2781 | if (idx >= 0) { |
| 2782 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2783 | label, type_idx, |
| 2784 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2785 | if (err < 0) |
| 2786 | return err; |
| 2787 | } |
| 2788 | } |
| 2789 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2790 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2791 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2792 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2793 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2794 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2795 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2796 | break; |
| 2797 | } |
| 2798 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2799 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2800 | |
| 2801 | spec->num_mux_defs = 1; |
| 2802 | spec->input_mux = imux; |
| 2803 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2804 | return 0; |
| 2805 | } |
| 2806 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2807 | /* create a shared input with the headphone out */ |
| 2808 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2809 | { |
| 2810 | struct alc_spec *spec = codec->spec; |
| 2811 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2812 | unsigned int defcfg; |
| 2813 | hda_nid_t nid; |
| 2814 | |
| 2815 | /* only one internal input pin? */ |
| 2816 | if (cfg->num_inputs != 1) |
| 2817 | return 0; |
| 2818 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2819 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2820 | return 0; |
| 2821 | |
| 2822 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2823 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2824 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2825 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2826 | else |
| 2827 | return 0; /* both not available */ |
| 2828 | |
| 2829 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2830 | return 0; /* no input */ |
| 2831 | |
| 2832 | cfg->inputs[1].pin = nid; |
| 2833 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2834 | cfg->num_inputs = 2; |
| 2835 | spec->shared_mic_hp = 1; |
| 2836 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2837 | return 0; |
| 2838 | } |
| 2839 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2840 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2841 | unsigned int pin_type) |
| 2842 | { |
| 2843 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2844 | pin_type); |
| 2845 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2846 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2847 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | d260cdf | 2008-02-13 17:19:35 +0100 | [diff] [blame] | 2848 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2849 | } |
| 2850 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2851 | static int get_pin_type(int line_out_type) |
| 2852 | { |
| 2853 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2854 | return PIN_HP; |
| 2855 | else |
| 2856 | return PIN_OUT; |
| 2857 | } |
| 2858 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2859 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2860 | { |
| 2861 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2862 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2863 | int i; |
| 2864 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2865 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2866 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2867 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2868 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2869 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2870 | snd_hda_codec_write(codec, nid, 0, |
| 2871 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2872 | AMP_OUT_MUTE); |
| 2873 | } |
| 2874 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2875 | |
| 2876 | /* mute all loopback inputs */ |
| 2877 | if (spec->mixer_nid) { |
| 2878 | int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); |
| 2879 | for (i = 0; i < nums; i++) |
| 2880 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2881 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2882 | AMP_IN_MUTE(i)); |
| 2883 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2884 | } |
| 2885 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2886 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2887 | static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2888 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2889 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2890 | int i, num; |
| 2891 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2892 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2893 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2894 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2895 | for (i = 0; i < num; i++) { |
| 2896 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2897 | return list[i]; |
| 2898 | } |
| 2899 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2900 | } |
| 2901 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2902 | /* go down to the selector widget before the mixer */ |
| 2903 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2904 | { |
| 2905 | hda_nid_t srcs[5]; |
| 2906 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2907 | ARRAY_SIZE(srcs)); |
| 2908 | if (num != 1 || |
| 2909 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2910 | return pin; |
| 2911 | return srcs[0]; |
| 2912 | } |
| 2913 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2914 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2915 | static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2916 | hda_nid_t dac) |
| 2917 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2918 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2919 | int i, num; |
| 2920 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2921 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2922 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2923 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2924 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2925 | return mix[i]; |
| 2926 | } |
| 2927 | return 0; |
| 2928 | } |
| 2929 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2930 | /* select the connection from pin to DAC if needed */ |
| 2931 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2932 | hda_nid_t dac) |
| 2933 | { |
| 2934 | hda_nid_t mix[5]; |
| 2935 | int i, num; |
| 2936 | |
| 2937 | pin = alc_go_down_to_selector(codec, pin); |
| 2938 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2939 | if (num < 2) |
| 2940 | return 0; |
| 2941 | for (i = 0; i < num; i++) { |
| 2942 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2943 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2944 | AC_VERB_SET_CONNECT_SEL, i); |
| 2945 | return 0; |
| 2946 | } |
| 2947 | } |
| 2948 | return 0; |
| 2949 | } |
| 2950 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2951 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2952 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2953 | { |
| 2954 | struct alc_spec *spec = codec->spec; |
| 2955 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2956 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2957 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2958 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2959 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2960 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2961 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2962 | if (!nid) |
| 2963 | continue; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2964 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 2965 | ARRAY_SIZE(spec->private_dac_nids))) |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2966 | continue; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2967 | if (found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2968 | ARRAY_SIZE(spec->multiout.hp_out_nid))) |
| 2969 | continue; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2970 | if (found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2971 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2972 | continue; |
| 2973 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2974 | } |
| 2975 | return 0; |
| 2976 | } |
| 2977 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2978 | /* check whether the DAC is reachable from the pin */ |
| 2979 | static bool alc_auto_is_dac_reachable(struct hda_codec *codec, |
| 2980 | hda_nid_t pin, hda_nid_t dac) |
| 2981 | { |
| 2982 | hda_nid_t srcs[5]; |
| 2983 | int i, num; |
| 2984 | |
| 2985 | pin = alc_go_down_to_selector(codec, pin); |
| 2986 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
| 2987 | for (i = 0; i < num; i++) { |
| 2988 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 2989 | if (nid == dac) |
| 2990 | return true; |
| 2991 | } |
| 2992 | return false; |
| 2993 | } |
| 2994 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2995 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2996 | { |
| 2997 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
| 2998 | if (snd_hda_get_conn_list(codec, sel, NULL) == 1) |
| 2999 | return alc_auto_look_for_dac(codec, pin); |
| 3000 | return 0; |
| 3001 | } |
| 3002 | |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3003 | /* return 0 if no possible DAC is found, 1 if one or more found */ |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3004 | static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs, |
| 3005 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3006 | { |
| 3007 | int i; |
| 3008 | |
| 3009 | if (num_outs && !dacs[0]) { |
| 3010 | dacs[0] = alc_auto_look_for_dac(codec, pins[0]); |
| 3011 | if (!dacs[0]) |
| 3012 | return 0; |
| 3013 | } |
| 3014 | |
| 3015 | for (i = 1; i < num_outs; i++) |
| 3016 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 3017 | for (i = 1; i < num_outs; i++) { |
| 3018 | if (!dacs[i]) |
| 3019 | dacs[i] = alc_auto_look_for_dac(codec, pins[i]); |
| 3020 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3021 | return 1; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3022 | } |
| 3023 | |
| 3024 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3025 | unsigned int location, int offset); |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3026 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3027 | hda_nid_t pin, hda_nid_t dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3028 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3029 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3030 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3031 | { |
| 3032 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3033 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3034 | unsigned int location, defcfg; |
| 3035 | int num_pins; |
Takashi Iwai | 350434e | 2011-06-30 21:29:12 +0200 | [diff] [blame] | 3036 | bool redone = false; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3037 | int i; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3038 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3039 | again: |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3040 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3041 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3042 | spec->multiout.hp_out_nid[0] = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3043 | spec->multiout.extra_out_nid[0] = 0; |
| 3044 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3045 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3046 | spec->multi_ios = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3047 | |
| 3048 | /* fill hard-wired DACs first */ |
| 3049 | if (!redone) { |
| 3050 | for (i = 0; i < cfg->line_outs; i++) |
| 3051 | spec->private_dac_nids[i] = |
| 3052 | get_dac_if_single(codec, cfg->line_out_pins[i]); |
| 3053 | if (cfg->hp_outs) |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3054 | spec->multiout.hp_out_nid[0] = |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3055 | get_dac_if_single(codec, cfg->hp_pins[0]); |
| 3056 | if (cfg->speaker_outs) |
| 3057 | spec->multiout.extra_out_nid[0] = |
| 3058 | get_dac_if_single(codec, cfg->speaker_pins[0]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3059 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3060 | |
| 3061 | for (i = 0; i < cfg->line_outs; i++) { |
| 3062 | hda_nid_t pin = cfg->line_out_pins[i]; |
| 3063 | if (spec->private_dac_nids[i]) |
| 3064 | continue; |
| 3065 | spec->private_dac_nids[i] = alc_auto_look_for_dac(codec, pin); |
| 3066 | if (!spec->private_dac_nids[i] && !redone) { |
| 3067 | /* if we can't find primary DACs, re-probe without |
| 3068 | * checking the hard-wired DACs |
| 3069 | */ |
| 3070 | redone = true; |
| 3071 | goto again; |
| 3072 | } |
| 3073 | } |
| 3074 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3075 | /* re-count num_dacs and squash invalid entries */ |
| 3076 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3077 | for (i = 0; i < cfg->line_outs; i++) { |
| 3078 | if (spec->private_dac_nids[i]) |
| 3079 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3080 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3081 | memmove(spec->private_dac_nids + i, |
| 3082 | spec->private_dac_nids + i + 1, |
| 3083 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3084 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3085 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3086 | } |
| 3087 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3088 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3089 | /* try to fill multi-io first */ |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3090 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]); |
| 3091 | location = get_defcfg_location(defcfg); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3092 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3093 | num_pins = alc_auto_fill_multi_ios(codec, location, 0); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3094 | if (num_pins > 0) { |
| 3095 | spec->multi_ios = num_pins; |
| 3096 | spec->ext_channel_count = 2; |
| 3097 | spec->multiout.num_dacs = num_pins + 1; |
| 3098 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3099 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3100 | |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3101 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) |
| 3102 | alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3103 | spec->multiout.hp_out_nid); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3104 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3105 | int err = alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, |
| 3106 | cfg->speaker_pins, |
| 3107 | spec->multiout.extra_out_nid); |
| 3108 | /* if no speaker volume is assigned, try again as the primary |
| 3109 | * output |
| 3110 | */ |
| 3111 | if (!err && cfg->speaker_outs > 0 && |
| 3112 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3113 | cfg->hp_outs = cfg->line_outs; |
| 3114 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3115 | sizeof(cfg->hp_pins)); |
| 3116 | cfg->line_outs = cfg->speaker_outs; |
| 3117 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3118 | sizeof(cfg->speaker_pins)); |
| 3119 | cfg->speaker_outs = 0; |
| 3120 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3121 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
| 3122 | redone = false; |
| 3123 | goto again; |
| 3124 | } |
| 3125 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3126 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3127 | if (!spec->multi_ios && |
| 3128 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3129 | cfg->hp_outs) { |
| 3130 | /* try multi-ios with HP + inputs */ |
| 3131 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->hp_pins[0]); |
| 3132 | location = get_defcfg_location(defcfg); |
| 3133 | |
| 3134 | num_pins = alc_auto_fill_multi_ios(codec, location, 1); |
| 3135 | if (num_pins > 0) { |
| 3136 | spec->multi_ios = num_pins; |
| 3137 | spec->ext_channel_count = 2; |
| 3138 | spec->multiout.num_dacs = num_pins + 1; |
| 3139 | } |
| 3140 | } |
| 3141 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3142 | if (cfg->line_out_pins[0]) |
| 3143 | spec->vmaster_nid = |
| 3144 | alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], |
| 3145 | spec->multiout.dac_nids[0]); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3146 | return 0; |
| 3147 | } |
| 3148 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3149 | static inline unsigned int get_ctl_pos(unsigned int data) |
| 3150 | { |
| 3151 | hda_nid_t nid = get_amp_nid_(data); |
| 3152 | unsigned int dir = get_amp_direction_(data); |
| 3153 | return (nid << 1) | dir; |
| 3154 | } |
| 3155 | |
| 3156 | #define is_ctl_used(bits, data) \ |
| 3157 | test_bit(get_ctl_pos(data), bits) |
| 3158 | #define mark_ctl_usage(bits, data) \ |
| 3159 | set_bit(get_ctl_pos(data), bits) |
| 3160 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3161 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3162 | const char *pfx, int cidx, |
| 3163 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3164 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3165 | struct alc_spec *spec = codec->spec; |
| 3166 | unsigned int val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3167 | if (!nid) |
| 3168 | return 0; |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3169 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3170 | if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ |
| 3171 | return 0; |
| 3172 | mark_ctl_usage(spec->vol_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3173 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3174 | val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3175 | } |
| 3176 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3177 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3178 | const char *pfx, int cidx, |
| 3179 | hda_nid_t nid) |
| 3180 | { |
| 3181 | int chs = 1; |
| 3182 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3183 | chs = 3; |
| 3184 | return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); |
| 3185 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3186 | |
| 3187 | /* create a mute-switch for the given mixer widget; |
| 3188 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3189 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3190 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3191 | const char *pfx, int cidx, |
| 3192 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3193 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3194 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3195 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3196 | int type; |
| 3197 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3198 | if (!nid) |
| 3199 | return 0; |
| 3200 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3201 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3202 | type = ALC_CTL_WIDGET_MUTE; |
| 3203 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3204 | } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3205 | type = ALC_CTL_WIDGET_MUTE; |
| 3206 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3207 | } else { |
| 3208 | type = ALC_CTL_BIND_MUTE; |
| 3209 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3210 | } |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3211 | if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ |
| 3212 | return 0; |
| 3213 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3214 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3215 | } |
| 3216 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3217 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
| 3218 | int cidx, hda_nid_t nid) |
| 3219 | { |
| 3220 | int chs = 1; |
| 3221 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3222 | chs = 3; |
| 3223 | return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); |
| 3224 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3225 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3226 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3227 | hda_nid_t pin, hda_nid_t dac) |
| 3228 | { |
| 3229 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3230 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3231 | return pin; |
| 3232 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3233 | return mix; |
| 3234 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3235 | return dac; |
| 3236 | return 0; |
| 3237 | } |
| 3238 | |
| 3239 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3240 | hda_nid_t pin, hda_nid_t dac) |
| 3241 | { |
| 3242 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3243 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3244 | return dac; |
| 3245 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3246 | return mix; |
| 3247 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3248 | return pin; |
| 3249 | return 0; |
| 3250 | } |
| 3251 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3252 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3253 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3254 | const struct auto_pin_cfg *cfg) |
| 3255 | { |
| 3256 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3257 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3258 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3259 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3260 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3261 | noutputs += spec->multi_ios; |
| 3262 | |
| 3263 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3264 | const char *name; |
| 3265 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3266 | hda_nid_t dac, pin; |
| 3267 | hda_nid_t sw, vol; |
| 3268 | |
| 3269 | dac = spec->multiout.dac_nids[i]; |
| 3270 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3271 | continue; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3272 | if (i >= cfg->line_outs) |
| 3273 | pin = spec->multi_io[i - 1].pin; |
| 3274 | else |
| 3275 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3276 | |
| 3277 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3278 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3279 | name = alc_get_line_out_pfx(spec, i, true, &index); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3280 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3281 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3282 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3283 | if (err < 0) |
| 3284 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3285 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3286 | if (err < 0) |
| 3287 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3288 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3289 | if (err < 0) |
| 3290 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3291 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3292 | if (err < 0) |
| 3293 | return err; |
| 3294 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3295 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3296 | if (err < 0) |
| 3297 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3298 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3299 | if (err < 0) |
| 3300 | return err; |
| 3301 | } |
| 3302 | } |
| 3303 | return 0; |
| 3304 | } |
| 3305 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3306 | 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] | 3307 | hda_nid_t dac, const char *pfx, |
| 3308 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3309 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3310 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3311 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3312 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3313 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3314 | if (!dac) { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3315 | unsigned int val; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3316 | /* the corresponding DAC is already occupied */ |
| 3317 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3318 | return 0; /* no way */ |
| 3319 | /* create a switch only */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3320 | val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); |
| 3321 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3322 | return 0; /* already created */ |
| 3323 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3324 | return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3325 | } |
| 3326 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3327 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3328 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3329 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3330 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3331 | return err; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3332 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3333 | if (err < 0) |
| 3334 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3335 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3336 | } |
| 3337 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3338 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3339 | unsigned int nums, |
| 3340 | struct hda_ctl_ops *ops) |
| 3341 | { |
| 3342 | struct alc_spec *spec = codec->spec; |
| 3343 | struct hda_bind_ctls **ctlp, *ctl; |
| 3344 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3345 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3346 | if (!ctlp) |
| 3347 | return NULL; |
| 3348 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3349 | *ctlp = ctl; |
| 3350 | if (ctl) |
| 3351 | ctl->ops = ops; |
| 3352 | return ctl; |
| 3353 | } |
| 3354 | |
| 3355 | /* add playback controls for speaker and HP outputs */ |
| 3356 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3357 | const hda_nid_t *pins, |
| 3358 | const hda_nid_t *dacs, |
| 3359 | const char *pfx) |
| 3360 | { |
| 3361 | struct alc_spec *spec = codec->spec; |
| 3362 | struct hda_bind_ctls *ctl; |
| 3363 | char name[32]; |
| 3364 | int i, n, err; |
| 3365 | |
| 3366 | if (!num_pins || !pins[0]) |
| 3367 | return 0; |
| 3368 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3369 | if (num_pins == 1) { |
| 3370 | hda_nid_t dac = *dacs; |
| 3371 | if (!dac) |
| 3372 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3373 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3374 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3375 | |
| 3376 | if (dacs[num_pins - 1]) { |
| 3377 | /* OK, we have a multi-output system with individual volumes */ |
| 3378 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3379 | if (num_pins >= 3) { |
| 3380 | snprintf(name, sizeof(name), "%s %s", |
| 3381 | pfx, channel_name[i]); |
| 3382 | err = alc_auto_create_extra_out(codec, pins[i], dacs[i], |
| 3383 | name, 0); |
| 3384 | } else { |
| 3385 | err = alc_auto_create_extra_out(codec, pins[i], dacs[i], |
| 3386 | pfx, i); |
| 3387 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3388 | if (err < 0) |
| 3389 | return err; |
| 3390 | } |
| 3391 | return 0; |
| 3392 | } |
| 3393 | |
| 3394 | /* Let's create a bind-controls */ |
| 3395 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_sw); |
| 3396 | if (!ctl) |
| 3397 | return -ENOMEM; |
| 3398 | n = 0; |
| 3399 | for (i = 0; i < num_pins; i++) { |
| 3400 | if (get_wcaps(codec, pins[i]) & AC_WCAP_OUT_AMP) |
| 3401 | ctl->values[n++] = |
| 3402 | HDA_COMPOSE_AMP_VAL(pins[i], 3, 0, HDA_OUTPUT); |
| 3403 | } |
| 3404 | if (n) { |
| 3405 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
| 3406 | err = add_control(spec, ALC_CTL_BIND_SW, name, 0, (long)ctl); |
| 3407 | if (err < 0) |
| 3408 | return err; |
| 3409 | } |
| 3410 | |
| 3411 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3412 | if (!ctl) |
| 3413 | return -ENOMEM; |
| 3414 | n = 0; |
| 3415 | for (i = 0; i < num_pins; i++) { |
| 3416 | hda_nid_t vol; |
| 3417 | if (!pins[i] || !dacs[i]) |
| 3418 | continue; |
| 3419 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3420 | if (vol) |
| 3421 | ctl->values[n++] = |
| 3422 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3423 | } |
| 3424 | if (n) { |
| 3425 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3426 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3427 | if (err < 0) |
| 3428 | return err; |
| 3429 | } |
| 3430 | return 0; |
| 3431 | } |
| 3432 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3433 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3434 | { |
| 3435 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3436 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3437 | spec->autocfg.hp_pins, |
| 3438 | spec->multiout.hp_out_nid, |
| 3439 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3440 | } |
| 3441 | |
| 3442 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3443 | { |
| 3444 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3445 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3446 | spec->autocfg.speaker_pins, |
| 3447 | spec->multiout.extra_out_nid, |
| 3448 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3449 | } |
| 3450 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3451 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3452 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3453 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3454 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3455 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3456 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3457 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3458 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3459 | alc_set_pin_output(codec, pin, pin_type); |
| 3460 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3461 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3462 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3463 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3464 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3465 | mix = srcs[i]; |
| 3466 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3467 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3468 | if (!mix) |
| 3469 | return; |
| 3470 | |
| 3471 | /* need the manual connection? */ |
| 3472 | if (num > 1) |
| 3473 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3474 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3475 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3476 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3477 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3478 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3479 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3480 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3481 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3482 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3483 | if (nid) |
| 3484 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3485 | AMP_OUT_ZERO); |
Takashi Iwai | 43dea22 | 2011-11-06 11:25:34 +0100 | [diff] [blame] | 3486 | |
| 3487 | /* unmute DAC if it's not assigned to a mixer */ |
| 3488 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3489 | if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3490 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3491 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3492 | } |
| 3493 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3494 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3495 | { |
| 3496 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3497 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3498 | int i; |
| 3499 | |
| 3500 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3501 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3502 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3503 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3504 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3505 | } |
| 3506 | } |
| 3507 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3508 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3509 | { |
| 3510 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3511 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3512 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3513 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3514 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3515 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3516 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3517 | pin = spec->autocfg.hp_pins[i]; |
| 3518 | if (!pin) |
| 3519 | break; |
| 3520 | dac = spec->multiout.hp_out_nid[i]; |
| 3521 | if (!dac) { |
| 3522 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3523 | dac = spec->multiout.hp_out_nid[0]; |
| 3524 | else |
| 3525 | dac = spec->multiout.dac_nids[0]; |
| 3526 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3527 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3528 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3529 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3530 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3531 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3532 | pin = spec->autocfg.speaker_pins[i]; |
| 3533 | if (!pin) |
| 3534 | break; |
| 3535 | dac = spec->multiout.extra_out_nid[i]; |
| 3536 | if (!dac) { |
| 3537 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3538 | dac = spec->multiout.extra_out_nid[0]; |
| 3539 | else |
| 3540 | dac = spec->multiout.dac_nids[0]; |
| 3541 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3542 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3543 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3544 | } |
| 3545 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3546 | /* |
| 3547 | * multi-io helper |
| 3548 | */ |
| 3549 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3550 | unsigned int location, |
| 3551 | int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3552 | { |
| 3553 | struct alc_spec *spec = codec->spec; |
| 3554 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3555 | hda_nid_t prime_dac = spec->private_dac_nids[0]; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3556 | int type, i, dacs, num_pins = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3557 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3558 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3559 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3560 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3561 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3562 | hda_nid_t dac = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3563 | unsigned int defcfg, caps; |
| 3564 | if (cfg->inputs[i].type != type) |
| 3565 | continue; |
| 3566 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3567 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3568 | continue; |
| 3569 | if (location && get_defcfg_location(defcfg) != location) |
| 3570 | continue; |
| 3571 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3572 | if (!(caps & AC_PINCAP_OUT)) |
| 3573 | continue; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3574 | if (offset && offset + num_pins < dacs) { |
| 3575 | dac = spec->private_dac_nids[offset + num_pins]; |
| 3576 | if (!alc_auto_is_dac_reachable(codec, nid, dac)) |
| 3577 | dac = 0; |
| 3578 | } |
| 3579 | if (!dac) |
| 3580 | dac = alc_auto_look_for_dac(codec, nid); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3581 | if (!dac) |
| 3582 | continue; |
| 3583 | spec->multi_io[num_pins].pin = nid; |
| 3584 | spec->multi_io[num_pins].dac = dac; |
| 3585 | num_pins++; |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 3586 | spec->private_dac_nids[spec->multiout.num_dacs++] = dac; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3587 | } |
| 3588 | } |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3589 | spec->multiout.num_dacs = dacs; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3590 | if (num_pins < 2) { |
| 3591 | /* clear up again */ |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3592 | memset(spec->private_dac_nids + dacs, 0, |
| 3593 | sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - dacs)); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3594 | spec->private_dac_nids[0] = prime_dac; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3595 | return 0; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3596 | } |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3597 | return num_pins; |
| 3598 | } |
| 3599 | |
| 3600 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3601 | struct snd_ctl_elem_info *uinfo) |
| 3602 | { |
| 3603 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3604 | struct alc_spec *spec = codec->spec; |
| 3605 | |
| 3606 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3607 | uinfo->count = 1; |
| 3608 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3609 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3610 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3611 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3612 | (uinfo->value.enumerated.item + 1) * 2); |
| 3613 | return 0; |
| 3614 | } |
| 3615 | |
| 3616 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3617 | struct snd_ctl_elem_value *ucontrol) |
| 3618 | { |
| 3619 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3620 | struct alc_spec *spec = codec->spec; |
| 3621 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3622 | return 0; |
| 3623 | } |
| 3624 | |
| 3625 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3626 | { |
| 3627 | struct alc_spec *spec = codec->spec; |
| 3628 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3629 | |
| 3630 | if (!spec->multi_io[idx].ctl_in) |
| 3631 | spec->multi_io[idx].ctl_in = |
| 3632 | snd_hda_codec_read(codec, nid, 0, |
| 3633 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3634 | if (output) { |
| 3635 | snd_hda_codec_update_cache(codec, nid, 0, |
| 3636 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3637 | PIN_OUT); |
| 3638 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3639 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3640 | HDA_AMP_MUTE, 0); |
| 3641 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 3642 | } else { |
| 3643 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3644 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3645 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
| 3646 | snd_hda_codec_update_cache(codec, nid, 0, |
| 3647 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3648 | spec->multi_io[idx].ctl_in); |
| 3649 | } |
| 3650 | return 0; |
| 3651 | } |
| 3652 | |
| 3653 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 3654 | struct snd_ctl_elem_value *ucontrol) |
| 3655 | { |
| 3656 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3657 | struct alc_spec *spec = codec->spec; |
| 3658 | int i, ch; |
| 3659 | |
| 3660 | ch = ucontrol->value.enumerated.item[0]; |
| 3661 | if (ch < 0 || ch > spec->multi_ios) |
| 3662 | return -EINVAL; |
| 3663 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 3664 | return 0; |
| 3665 | spec->ext_channel_count = (ch + 1) * 2; |
| 3666 | for (i = 0; i < spec->multi_ios; i++) |
| 3667 | alc_set_multi_io(codec, i, i < ch); |
| 3668 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 3669 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 3670 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3671 | return 1; |
| 3672 | } |
| 3673 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 3674 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3675 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3676 | .name = "Channel Mode", |
| 3677 | .info = alc_auto_ch_mode_info, |
| 3678 | .get = alc_auto_ch_mode_get, |
| 3679 | .put = alc_auto_ch_mode_put, |
| 3680 | }; |
| 3681 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3682 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3683 | { |
| 3684 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3685 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3686 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3687 | struct snd_kcontrol_new *knew; |
| 3688 | |
| 3689 | knew = alc_kcontrol_new(spec); |
| 3690 | if (!knew) |
| 3691 | return -ENOMEM; |
| 3692 | *knew = alc_auto_channel_mode_enum; |
| 3693 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 3694 | if (!knew->name) |
| 3695 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3696 | } |
| 3697 | return 0; |
| 3698 | } |
| 3699 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3700 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 3701 | * active input pins |
| 3702 | */ |
| 3703 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 3704 | { |
| 3705 | struct alc_spec *spec = codec->spec; |
| 3706 | const struct hda_input_mux *imux; |
| 3707 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 3708 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 3709 | int i, n, nums; |
| 3710 | |
| 3711 | imux = spec->input_mux; |
| 3712 | if (!imux) |
| 3713 | return; |
| 3714 | if (spec->dyn_adc_switch) |
| 3715 | return; |
| 3716 | |
| 3717 | nums = 0; |
| 3718 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 3719 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
| 3720 | int num_conns = snd_hda_get_conn_list(codec, cap, NULL); |
| 3721 | for (i = 0; i < imux->num_items; i++) { |
| 3722 | hda_nid_t pin = spec->imux_pins[i]; |
| 3723 | if (pin) { |
| 3724 | if (get_connection_index(codec, cap, pin) < 0) |
| 3725 | break; |
| 3726 | } else if (num_conns <= imux->items[i].index) |
| 3727 | break; |
| 3728 | } |
| 3729 | if (i >= imux->num_items) { |
| 3730 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 3731 | capsrc_nids[nums++] = cap; |
| 3732 | } |
| 3733 | } |
| 3734 | if (!nums) { |
| 3735 | /* check whether ADC-switch is possible */ |
| 3736 | if (!alc_check_dyn_adc_switch(codec)) { |
| 3737 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 3738 | " using fallback 0x%x\n", |
| 3739 | codec->chip_name, spec->private_adc_nids[0]); |
| 3740 | spec->num_adc_nids = 1; |
| 3741 | spec->auto_mic = 0; |
| 3742 | return; |
| 3743 | } |
| 3744 | } else if (nums != spec->num_adc_nids) { |
| 3745 | memcpy(spec->private_adc_nids, adc_nids, |
| 3746 | nums * sizeof(hda_nid_t)); |
| 3747 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 3748 | nums * sizeof(hda_nid_t)); |
| 3749 | spec->num_adc_nids = nums; |
| 3750 | } |
| 3751 | |
| 3752 | if (spec->auto_mic) |
| 3753 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
| 3754 | else if (spec->input_mux->num_items == 1) |
| 3755 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 3756 | } |
| 3757 | |
| 3758 | /* |
| 3759 | * initialize ADC paths |
| 3760 | */ |
| 3761 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 3762 | { |
| 3763 | struct alc_spec *spec = codec->spec; |
| 3764 | hda_nid_t nid; |
| 3765 | |
| 3766 | nid = spec->adc_nids[adc_idx]; |
| 3767 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3768 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3769 | snd_hda_codec_write(codec, nid, 0, |
| 3770 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3771 | AMP_IN_MUTE(0)); |
| 3772 | return; |
| 3773 | } |
| 3774 | if (!spec->capsrc_nids) |
| 3775 | return; |
| 3776 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3777 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3778 | snd_hda_codec_write(codec, nid, 0, |
| 3779 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3780 | AMP_OUT_MUTE); |
| 3781 | } |
| 3782 | |
| 3783 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 3784 | { |
| 3785 | struct alc_spec *spec = codec->spec; |
| 3786 | int c, nums; |
| 3787 | |
| 3788 | for (c = 0; c < spec->num_adc_nids; c++) |
| 3789 | alc_auto_init_adc(codec, c); |
| 3790 | if (spec->dyn_adc_switch) |
| 3791 | nums = 1; |
| 3792 | else |
| 3793 | nums = spec->num_adc_nids; |
| 3794 | for (c = 0; c < nums; c++) |
| 3795 | alc_mux_select(codec, 0, spec->cur_mux[c], true); |
| 3796 | } |
| 3797 | |
| 3798 | /* add mic boosts if needed */ |
| 3799 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 3800 | { |
| 3801 | struct alc_spec *spec = codec->spec; |
| 3802 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3803 | int i, err; |
| 3804 | int type_idx = 0; |
| 3805 | hda_nid_t nid; |
| 3806 | const char *prev_label = NULL; |
| 3807 | |
| 3808 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3809 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 3810 | break; |
| 3811 | nid = cfg->inputs[i].pin; |
| 3812 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 3813 | const char *label; |
| 3814 | char boost_label[32]; |
| 3815 | |
| 3816 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 3817 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 3818 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3819 | if (prev_label && !strcmp(label, prev_label)) |
| 3820 | type_idx++; |
| 3821 | else |
| 3822 | type_idx = 0; |
| 3823 | prev_label = label; |
| 3824 | |
| 3825 | snprintf(boost_label, sizeof(boost_label), |
| 3826 | "%s Boost Volume", label); |
| 3827 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 3828 | boost_label, type_idx, |
| 3829 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 3830 | if (err < 0) |
| 3831 | return err; |
| 3832 | } |
| 3833 | } |
| 3834 | return 0; |
| 3835 | } |
| 3836 | |
| 3837 | /* select or unmute the given capsrc route */ |
| 3838 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 3839 | int idx) |
| 3840 | { |
| 3841 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 3842 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 3843 | HDA_AMP_MUTE, 0); |
| 3844 | } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { |
| 3845 | snd_hda_codec_write_cache(codec, cap, 0, |
| 3846 | AC_VERB_SET_CONNECT_SEL, idx); |
| 3847 | } |
| 3848 | } |
| 3849 | |
| 3850 | /* set the default connection to that pin */ |
| 3851 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 3852 | { |
| 3853 | struct alc_spec *spec = codec->spec; |
| 3854 | int i; |
| 3855 | |
| 3856 | if (!pin) |
| 3857 | return 0; |
| 3858 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 3859 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3860 | int idx; |
| 3861 | |
| 3862 | idx = get_connection_index(codec, cap, pin); |
| 3863 | if (idx < 0) |
| 3864 | continue; |
| 3865 | select_or_unmute_capsrc(codec, cap, idx); |
| 3866 | return i; /* return the found index */ |
| 3867 | } |
| 3868 | return -1; /* not found */ |
| 3869 | } |
| 3870 | |
| 3871 | /* initialize some special cases for input sources */ |
| 3872 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 3873 | { |
| 3874 | struct alc_spec *spec = codec->spec; |
| 3875 | int i; |
| 3876 | |
| 3877 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 3878 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 3879 | } |
| 3880 | |
| 3881 | /* assign appropriate capture mixers */ |
| 3882 | static void set_capture_mixer(struct hda_codec *codec) |
| 3883 | { |
| 3884 | struct alc_spec *spec = codec->spec; |
| 3885 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 3886 | { alc_capture_mixer_nosrc1, |
| 3887 | alc_capture_mixer_nosrc2, |
| 3888 | alc_capture_mixer_nosrc3 }, |
| 3889 | { alc_capture_mixer1, |
| 3890 | alc_capture_mixer2, |
| 3891 | alc_capture_mixer3 }, |
| 3892 | }; |
| 3893 | |
| 3894 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3895 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3896 | if (!spec->capsrc_nids) |
| 3897 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3898 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3899 | return; /* no volume in capsrc, too */ |
| 3900 | spec->vol_in_capsrc = 1; |
| 3901 | } |
| 3902 | |
| 3903 | if (spec->num_adc_nids > 0) { |
| 3904 | int mux = 0; |
| 3905 | int num_adcs = 0; |
| 3906 | |
| 3907 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 3908 | mux = 1; |
| 3909 | if (spec->auto_mic) { |
| 3910 | num_adcs = 1; |
| 3911 | mux = 0; |
| 3912 | } else if (spec->dyn_adc_switch) |
| 3913 | num_adcs = 1; |
| 3914 | if (!num_adcs) { |
| 3915 | if (spec->num_adc_nids > 3) |
| 3916 | spec->num_adc_nids = 3; |
| 3917 | else if (!spec->num_adc_nids) |
| 3918 | return; |
| 3919 | num_adcs = spec->num_adc_nids; |
| 3920 | } |
| 3921 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 3922 | } |
| 3923 | } |
| 3924 | |
| 3925 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 3926 | * standard auto-parser initializations |
| 3927 | */ |
| 3928 | static void alc_auto_init_std(struct hda_codec *codec) |
| 3929 | { |
| 3930 | struct alc_spec *spec = codec->spec; |
| 3931 | alc_auto_init_multi_out(codec); |
| 3932 | alc_auto_init_extra_out(codec); |
| 3933 | alc_auto_init_analog_input(codec); |
| 3934 | alc_auto_init_input_src(codec); |
| 3935 | alc_auto_init_digital(codec); |
| 3936 | if (spec->unsol_event) |
| 3937 | alc_inithook(codec); |
| 3938 | } |
| 3939 | |
| 3940 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3941 | * Digital-beep handlers |
| 3942 | */ |
| 3943 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3944 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 3945 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 3946 | |
| 3947 | static const struct snd_pci_quirk beep_white_list[] = { |
| 3948 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 3949 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 3950 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 3951 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
| 3952 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 3953 | {} |
| 3954 | }; |
| 3955 | |
| 3956 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 3957 | { |
| 3958 | struct alc_spec *spec = codec->spec; |
| 3959 | const struct snd_pci_quirk *q; |
| 3960 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 3961 | if (q) |
| 3962 | return q->value; |
| 3963 | return spec->cdefine.enable_pcbeep; |
| 3964 | } |
| 3965 | #else |
| 3966 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 3967 | #define has_cdefine_beep(codec) 0 |
| 3968 | #endif |
| 3969 | |
| 3970 | /* parse the BIOS configuration and set up the alc_spec */ |
| 3971 | /* return 1 if successful, 0 if the proper config is not found, |
| 3972 | * or a negative error code |
| 3973 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3974 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 3975 | const hda_nid_t *ignore_nids, |
| 3976 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3977 | { |
| 3978 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3979 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3980 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3981 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 3982 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 3983 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3984 | if (err < 0) |
| 3985 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3986 | if (!cfg->line_outs) { |
| 3987 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3988 | spec->multiout.max_channels = 2; |
| 3989 | spec->no_analog = 1; |
| 3990 | goto dig_only; |
| 3991 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3992 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3993 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3994 | |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 3995 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3996 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3997 | /* use HP as primary out */ |
| 3998 | cfg->speaker_outs = cfg->line_outs; |
| 3999 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4000 | sizeof(cfg->speaker_pins)); |
| 4001 | cfg->line_outs = cfg->hp_outs; |
| 4002 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4003 | cfg->hp_outs = 0; |
| 4004 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4005 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4006 | } |
| 4007 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4008 | err = alc_auto_fill_dac_nids(codec); |
| 4009 | if (err < 0) |
| 4010 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4011 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4012 | if (err < 0) |
| 4013 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4014 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4015 | if (err < 0) |
| 4016 | return err; |
| 4017 | err = alc_auto_create_hp_out(codec); |
| 4018 | if (err < 0) |
| 4019 | return err; |
| 4020 | err = alc_auto_create_speaker_out(codec); |
| 4021 | if (err < 0) |
| 4022 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4023 | err = alc_auto_create_shared_input(codec); |
| 4024 | if (err < 0) |
| 4025 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4026 | err = alc_auto_create_input_ctls(codec); |
| 4027 | if (err < 0) |
| 4028 | return err; |
| 4029 | |
| 4030 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4031 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4032 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4033 | alc_auto_parse_digital(codec); |
| 4034 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4035 | if (!spec->no_analog) |
| 4036 | alc_remove_invalid_adc_nids(codec); |
| 4037 | |
| 4038 | if (ssid_nids) |
| 4039 | alc_ssid_check(codec, ssid_nids); |
| 4040 | |
| 4041 | if (!spec->no_analog) { |
| 4042 | alc_auto_check_switches(codec); |
| 4043 | err = alc_auto_add_mic_boost(codec); |
| 4044 | if (err < 0) |
| 4045 | return err; |
| 4046 | } |
| 4047 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4048 | if (spec->kctls.list) |
| 4049 | add_mixer(spec, spec->kctls.list); |
| 4050 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4051 | return 1; |
| 4052 | } |
| 4053 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4054 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4055 | { |
| 4056 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
| 4057 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 4058 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4059 | } |
| 4060 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4061 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4062 | static const struct hda_amp_list alc880_loopbacks[] = { |
| 4063 | { 0x0b, HDA_INPUT, 0 }, |
| 4064 | { 0x0b, HDA_INPUT, 1 }, |
| 4065 | { 0x0b, HDA_INPUT, 2 }, |
| 4066 | { 0x0b, HDA_INPUT, 3 }, |
| 4067 | { 0x0b, HDA_INPUT, 4 }, |
| 4068 | { } /* end */ |
| 4069 | }; |
| 4070 | #endif |
| 4071 | |
| 4072 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4073 | * ALC880 fix-ups |
| 4074 | */ |
| 4075 | enum { |
| 4076 | ALC880_FIXUP_GPIO2, |
| 4077 | ALC880_FIXUP_MEDION_RIM, |
| 4078 | }; |
| 4079 | |
| 4080 | static const struct alc_fixup alc880_fixups[] = { |
| 4081 | [ALC880_FIXUP_GPIO2] = { |
| 4082 | .type = ALC_FIXUP_VERBS, |
| 4083 | .v.verbs = alc_gpio2_init_verbs, |
| 4084 | }, |
| 4085 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4086 | .type = ALC_FIXUP_VERBS, |
| 4087 | .v.verbs = (const struct hda_verb[]) { |
| 4088 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4089 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4090 | { } |
| 4091 | }, |
| 4092 | .chained = true, |
| 4093 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4094 | }, |
| 4095 | }; |
| 4096 | |
| 4097 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
| 4098 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
| 4099 | {} |
| 4100 | }; |
| 4101 | |
| 4102 | |
| 4103 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4104 | * board setups |
| 4105 | */ |
| 4106 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4107 | #define alc_board_config \ |
| 4108 | snd_hda_check_board_config |
| 4109 | #define alc_board_codec_sid_config \ |
| 4110 | snd_hda_check_board_codec_sid_config |
| 4111 | #include "alc_quirks.c" |
| 4112 | #else |
| 4113 | #define alc_board_config(codec, nums, models, tbl) -1 |
| 4114 | #define alc_board_codec_sid_config(codec, nums, models, tbl) -1 |
| 4115 | #define setup_preset(codec, x) /* NOP */ |
| 4116 | #endif |
| 4117 | |
| 4118 | /* |
| 4119 | * OK, here we have finally the patch for ALC880 |
| 4120 | */ |
| 4121 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4122 | #include "alc880_quirks.c" |
| 4123 | #endif |
| 4124 | |
| 4125 | static int patch_alc880(struct hda_codec *codec) |
| 4126 | { |
| 4127 | struct alc_spec *spec; |
| 4128 | int board_config; |
| 4129 | int err; |
| 4130 | |
| 4131 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4132 | if (spec == NULL) |
| 4133 | return -ENOMEM; |
| 4134 | |
| 4135 | codec->spec = spec; |
| 4136 | |
| 4137 | spec->mixer_nid = 0x0b; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4138 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4139 | |
| 4140 | board_config = alc_board_config(codec, ALC880_MODEL_LAST, |
| 4141 | alc880_models, alc880_cfg_tbl); |
| 4142 | if (board_config < 0) { |
| 4143 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4144 | codec->chip_name); |
| 4145 | board_config = ALC_MODEL_AUTO; |
| 4146 | } |
| 4147 | |
| 4148 | if (board_config == ALC_MODEL_AUTO) { |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4149 | alc_pick_fixup(codec, NULL, alc880_fixup_tbl, alc880_fixups); |
| 4150 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 4151 | } |
| 4152 | |
| 4153 | if (board_config == ALC_MODEL_AUTO) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4154 | /* automatic parse from the BIOS config */ |
| 4155 | err = alc880_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4156 | if (err < 0) |
| 4157 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4158 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4159 | else if (!err) { |
| 4160 | printk(KERN_INFO |
| 4161 | "hda_codec: Cannot set up configuration " |
| 4162 | "from BIOS. Using 3-stack mode...\n"); |
| 4163 | board_config = ALC880_3ST; |
| 4164 | } |
| 4165 | #endif |
| 4166 | } |
| 4167 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 4168 | if (board_config != ALC_MODEL_AUTO) { |
| 4169 | spec->vmaster_nid = 0x0c; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4170 | setup_preset(codec, &alc880_presets[board_config]); |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 4171 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4172 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4173 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4174 | alc_auto_fill_adc_caps(codec); |
| 4175 | alc_rebuild_imux_for_auto_mic(codec); |
| 4176 | alc_remove_invalid_adc_nids(codec); |
| 4177 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4178 | |
| 4179 | if (!spec->no_analog && !spec->cap_mixer) |
| 4180 | set_capture_mixer(codec); |
| 4181 | |
| 4182 | if (!spec->no_analog) { |
| 4183 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4184 | if (err < 0) |
| 4185 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4186 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4187 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4188 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4189 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4190 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4191 | codec->patch_ops = alc_patch_ops; |
| 4192 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4193 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 4194 | else |
| 4195 | codec->patch_ops.build_controls = __alc_build_controls; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4196 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4197 | if (!spec->loopback.amplist) |
| 4198 | spec->loopback.amplist = alc880_loopbacks; |
| 4199 | #endif |
| 4200 | |
| 4201 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4202 | |
| 4203 | error: |
| 4204 | alc_free(codec); |
| 4205 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4206 | } |
| 4207 | |
| 4208 | |
| 4209 | /* |
| 4210 | * ALC260 support |
| 4211 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4212 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4213 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4214 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4215 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4216 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4217 | } |
| 4218 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4219 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4220 | static const struct hda_amp_list alc260_loopbacks[] = { |
| 4221 | { 0x07, HDA_INPUT, 0 }, |
| 4222 | { 0x07, HDA_INPUT, 1 }, |
| 4223 | { 0x07, HDA_INPUT, 2 }, |
| 4224 | { 0x07, HDA_INPUT, 3 }, |
| 4225 | { 0x07, HDA_INPUT, 4 }, |
| 4226 | { } /* end */ |
| 4227 | }; |
| 4228 | #endif |
| 4229 | |
| 4230 | /* |
| 4231 | * Pin config fixes |
| 4232 | */ |
| 4233 | enum { |
| 4234 | PINFIX_HP_DC5750, |
| 4235 | }; |
| 4236 | |
| 4237 | static const struct alc_fixup alc260_fixups[] = { |
| 4238 | [PINFIX_HP_DC5750] = { |
| 4239 | .type = ALC_FIXUP_PINS, |
| 4240 | .v.pins = (const struct alc_pincfg[]) { |
| 4241 | { 0x11, 0x90130110 }, /* speaker */ |
| 4242 | { } |
| 4243 | } |
| 4244 | }, |
| 4245 | }; |
| 4246 | |
| 4247 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
| 4248 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750), |
| 4249 | {} |
| 4250 | }; |
| 4251 | |
| 4252 | /* |
| 4253 | */ |
| 4254 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4255 | #include "alc260_quirks.c" |
| 4256 | #endif |
| 4257 | |
| 4258 | static int patch_alc260(struct hda_codec *codec) |
| 4259 | { |
| 4260 | struct alc_spec *spec; |
| 4261 | int err, board_config; |
| 4262 | |
| 4263 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4264 | if (spec == NULL) |
| 4265 | return -ENOMEM; |
| 4266 | |
| 4267 | codec->spec = spec; |
| 4268 | |
| 4269 | spec->mixer_nid = 0x07; |
| 4270 | |
| 4271 | board_config = alc_board_config(codec, ALC260_MODEL_LAST, |
| 4272 | alc260_models, alc260_cfg_tbl); |
| 4273 | if (board_config < 0) { |
| 4274 | snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4275 | codec->chip_name); |
| 4276 | board_config = ALC_MODEL_AUTO; |
| 4277 | } |
| 4278 | |
| 4279 | if (board_config == ALC_MODEL_AUTO) { |
| 4280 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 4281 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 4282 | } |
| 4283 | |
| 4284 | if (board_config == ALC_MODEL_AUTO) { |
| 4285 | /* automatic parse from the BIOS config */ |
| 4286 | err = alc260_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4287 | if (err < 0) |
| 4288 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4289 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4290 | else if (!err) { |
| 4291 | printk(KERN_INFO |
| 4292 | "hda_codec: Cannot set up configuration " |
| 4293 | "from BIOS. Using base mode...\n"); |
| 4294 | board_config = ALC260_BASIC; |
| 4295 | } |
| 4296 | #endif |
| 4297 | } |
| 4298 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 4299 | if (board_config != ALC_MODEL_AUTO) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4300 | setup_preset(codec, &alc260_presets[board_config]); |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 4301 | spec->vmaster_nid = 0x08; |
| 4302 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4303 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4304 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4305 | alc_auto_fill_adc_caps(codec); |
| 4306 | alc_rebuild_imux_for_auto_mic(codec); |
| 4307 | alc_remove_invalid_adc_nids(codec); |
| 4308 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4309 | |
| 4310 | if (!spec->no_analog && !spec->cap_mixer) |
| 4311 | set_capture_mixer(codec); |
| 4312 | |
| 4313 | if (!spec->no_analog) { |
| 4314 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4315 | if (err < 0) |
| 4316 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4317 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 4318 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4319 | |
| 4320 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4321 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4322 | codec->patch_ops = alc_patch_ops; |
| 4323 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | 8452a98 | 2011-07-08 16:19:48 +0200 | [diff] [blame] | 4324 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 4325 | else |
| 4326 | codec->patch_ops.build_controls = __alc_build_controls; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4327 | spec->shutup = alc_eapd_shutup; |
| 4328 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4329 | if (!spec->loopback.amplist) |
| 4330 | spec->loopback.amplist = alc260_loopbacks; |
| 4331 | #endif |
| 4332 | |
| 4333 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4334 | |
| 4335 | error: |
| 4336 | alc_free(codec); |
| 4337 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4338 | } |
| 4339 | |
| 4340 | |
| 4341 | /* |
| 4342 | * ALC882/883/885/888/889 support |
| 4343 | * |
| 4344 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 4345 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 4346 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 4347 | * 6-channel independent captures. |
| 4348 | * |
| 4349 | * In addition, an independent DAC for the multi-playback (not used in this |
| 4350 | * driver yet). |
| 4351 | */ |
| 4352 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4353 | #define alc882_loopbacks alc880_loopbacks |
| 4354 | #endif |
| 4355 | |
| 4356 | /* |
| 4357 | * Pin config fixes |
| 4358 | */ |
| 4359 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4360 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 4361 | ALC882_FIXUP_LENOVO_Y530, |
| 4362 | ALC882_FIXUP_PB_M5210, |
| 4363 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 4364 | ALC882_FIXUP_ASUS_W90V, |
| 4365 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 4366 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 4367 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 4368 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 4369 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 4370 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4371 | ALC889_FIXUP_COEF, |
| 4372 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 4373 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 4374 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 4375 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 4376 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4377 | }; |
| 4378 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4379 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 4380 | const struct alc_fixup *fix, int action) |
| 4381 | { |
| 4382 | if (action != ALC_FIXUP_ACT_INIT) |
| 4383 | return; |
| 4384 | alc889_coef_init(codec); |
| 4385 | } |
| 4386 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 4387 | /* toggle speaker-output according to the hp-jack state */ |
| 4388 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 4389 | { |
| 4390 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4391 | |
| 4392 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4393 | AC_VERB_GET_GPIO_DATA, 0); |
| 4394 | |
| 4395 | if (!muted) |
| 4396 | gpiostate |= (1 << pin); |
| 4397 | else |
| 4398 | gpiostate &= ~(1 << pin); |
| 4399 | |
| 4400 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4401 | AC_VERB_GET_GPIO_MASK, 0); |
| 4402 | gpiomask |= (1 << pin); |
| 4403 | |
| 4404 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4405 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 4406 | gpiodir |= (1 << pin); |
| 4407 | |
| 4408 | |
| 4409 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4410 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 4411 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4412 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 4413 | |
| 4414 | msleep(1); |
| 4415 | |
| 4416 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4417 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 4418 | } |
| 4419 | |
| 4420 | /* set up GPIO at initialization */ |
| 4421 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 4422 | const struct alc_fixup *fix, int action) |
| 4423 | { |
| 4424 | if (action != ALC_FIXUP_ACT_INIT) |
| 4425 | return; |
| 4426 | alc882_gpio_mute(codec, 0, 0); |
| 4427 | alc882_gpio_mute(codec, 1, 0); |
| 4428 | } |
| 4429 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4430 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4431 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4432 | .type = ALC_FIXUP_PINS, |
| 4433 | .v.pins = (const struct alc_pincfg[]) { |
| 4434 | { 0x15, 0x01080104 }, /* side */ |
| 4435 | { 0x16, 0x01011012 }, /* rear */ |
| 4436 | { 0x17, 0x01016011 }, /* clfe */ |
| 4437 | { } |
| 4438 | } |
| 4439 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4440 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4441 | .type = ALC_FIXUP_PINS, |
| 4442 | .v.pins = (const struct alc_pincfg[]) { |
| 4443 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 4444 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 4445 | { } |
| 4446 | } |
| 4447 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4448 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4449 | .type = ALC_FIXUP_VERBS, |
| 4450 | .v.verbs = (const struct hda_verb[]) { |
| 4451 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 4452 | {} |
| 4453 | } |
| 4454 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4455 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4456 | .type = ALC_FIXUP_SKU, |
| 4457 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 4458 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4459 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 4460 | .type = ALC_FIXUP_PINS, |
| 4461 | .v.pins = (const struct alc_pincfg[]) { |
| 4462 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 4463 | { } |
| 4464 | } |
| 4465 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4466 | [ALC889_FIXUP_VAIO_TT] = { |
| 4467 | .type = ALC_FIXUP_PINS, |
| 4468 | .v.pins = (const struct alc_pincfg[]) { |
| 4469 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 4470 | { } |
| 4471 | } |
| 4472 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 4473 | [ALC888_FIXUP_EEE1601] = { |
| 4474 | .type = ALC_FIXUP_VERBS, |
| 4475 | .v.verbs = (const struct hda_verb[]) { |
| 4476 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 4477 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 4478 | { } |
| 4479 | } |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 4480 | }, |
| 4481 | [ALC882_FIXUP_EAPD] = { |
| 4482 | .type = ALC_FIXUP_VERBS, |
| 4483 | .v.verbs = (const struct hda_verb[]) { |
| 4484 | /* change to EAPD mode */ |
| 4485 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4486 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4487 | { } |
| 4488 | } |
| 4489 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 4490 | [ALC883_FIXUP_EAPD] = { |
| 4491 | .type = ALC_FIXUP_VERBS, |
| 4492 | .v.verbs = (const struct hda_verb[]) { |
| 4493 | /* change to EAPD mode */ |
| 4494 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4495 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4496 | { } |
| 4497 | } |
| 4498 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 4499 | [ALC883_FIXUP_ACER_EAPD] = { |
| 4500 | .type = ALC_FIXUP_VERBS, |
| 4501 | .v.verbs = (const struct hda_verb[]) { |
| 4502 | /* eanable EAPD on Acer laptops */ |
| 4503 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4504 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4505 | { } |
| 4506 | } |
| 4507 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 4508 | [ALC882_FIXUP_GPIO3] = { |
| 4509 | .type = ALC_FIXUP_VERBS, |
| 4510 | .v.verbs = alc_gpio3_init_verbs, |
| 4511 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4512 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 4513 | .type = ALC_FIXUP_VERBS, |
| 4514 | .v.verbs = alc_gpio1_init_verbs, |
| 4515 | .chained = true, |
| 4516 | .chain_id = ALC882_FIXUP_EAPD, |
| 4517 | }, |
| 4518 | [ALC889_FIXUP_COEF] = { |
| 4519 | .type = ALC_FIXUP_FUNC, |
| 4520 | .v.func = alc889_fixup_coef, |
| 4521 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 4522 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 4523 | .type = ALC_FIXUP_PINS, |
| 4524 | .v.pins = (const struct alc_pincfg[]) { |
| 4525 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 4526 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 4527 | { } |
| 4528 | } |
| 4529 | }, |
| 4530 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 4531 | .type = ALC_FIXUP_PINS, |
| 4532 | .v.pins = (const struct alc_pincfg[]) { |
| 4533 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 4534 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 4535 | { } |
| 4536 | }, |
| 4537 | .chained = true, |
| 4538 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 4539 | }, |
| 4540 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 4541 | /* additional init verbs for Acer Aspire 8930G */ |
| 4542 | .type = ALC_FIXUP_VERBS, |
| 4543 | .v.verbs = (const struct hda_verb[]) { |
| 4544 | /* Enable all DACs */ |
| 4545 | /* DAC DISABLE/MUTE 1? */ |
| 4546 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 4547 | * apparently. Init=0x38 */ |
| 4548 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 4549 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 4550 | /* DAC DISABLE/MUTE 2? */ |
| 4551 | /* some bit here disables the other DACs. |
| 4552 | * Init=0x4900 */ |
| 4553 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 4554 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 4555 | /* DMIC fix |
| 4556 | * This laptop has a stereo digital microphone. |
| 4557 | * The mics are only 1cm apart which makes the stereo |
| 4558 | * useless. However, either the mic or the ALC889 |
| 4559 | * makes the signal become a difference/sum signal |
| 4560 | * instead of standard stereo, which is annoying. |
| 4561 | * So instead we flip this bit which makes the |
| 4562 | * codec replicate the sum signal to both channels, |
| 4563 | * turning it into a normal mono mic. |
| 4564 | */ |
| 4565 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 4566 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 4567 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 4568 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4569 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4570 | { } |
| 4571 | } |
| 4572 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 4573 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 4574 | .type = ALC_FIXUP_FUNC, |
| 4575 | .v.func = alc885_fixup_macpro_gpio, |
| 4576 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4577 | }; |
| 4578 | |
| 4579 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 4580 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 4581 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 4582 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 4583 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 4584 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 4585 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 4586 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 4587 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 4588 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 4589 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 4590 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 4591 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 4592 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 4593 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 4594 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 4595 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 4596 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 4597 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 4598 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 4599 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4600 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 4601 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 4602 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4603 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4604 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 4605 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 4606 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 4607 | |
| 4608 | /* All Apple entries are in codec SSIDs */ |
| 4609 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 4610 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 4611 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
| 4612 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
| 4613 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
| 4614 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 4615 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 4616 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4617 | 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] | 4618 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 4619 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 4620 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4621 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4622 | {} |
| 4623 | }; |
| 4624 | |
| 4625 | /* |
| 4626 | * BIOS auto configuration |
| 4627 | */ |
| 4628 | /* almost identical with ALC880 parser... */ |
| 4629 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 4630 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4631 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4632 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 4633 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4634 | } |
| 4635 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4636 | /* |
| 4637 | */ |
| 4638 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4639 | #include "alc882_quirks.c" |
| 4640 | #endif |
| 4641 | |
| 4642 | static int patch_alc882(struct hda_codec *codec) |
| 4643 | { |
| 4644 | struct alc_spec *spec; |
| 4645 | int err, board_config; |
| 4646 | |
| 4647 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4648 | if (spec == NULL) |
| 4649 | return -ENOMEM; |
| 4650 | |
| 4651 | codec->spec = spec; |
| 4652 | |
| 4653 | spec->mixer_nid = 0x0b; |
| 4654 | |
| 4655 | switch (codec->vendor_id) { |
| 4656 | case 0x10ec0882: |
| 4657 | case 0x10ec0885: |
| 4658 | break; |
| 4659 | default: |
| 4660 | /* ALC883 and variants */ |
| 4661 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 4662 | break; |
| 4663 | } |
| 4664 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4665 | err = alc_codec_rename_from_preset(codec); |
| 4666 | if (err < 0) |
| 4667 | goto error; |
| 4668 | |
Takashi Iwai | b253969 | 2011-11-14 17:32:17 +0100 | [diff] [blame] | 4669 | board_config = alc_board_config(codec, ALC882_MODEL_LAST, |
| 4670 | alc882_models, NULL); |
| 4671 | if (board_config < 0) |
| 4672 | board_config = alc_board_codec_sid_config(codec, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4673 | ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl); |
| 4674 | |
| 4675 | if (board_config < 0) { |
| 4676 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4677 | codec->chip_name); |
| 4678 | board_config = ALC_MODEL_AUTO; |
| 4679 | } |
| 4680 | |
| 4681 | if (board_config == ALC_MODEL_AUTO) { |
| 4682 | alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups); |
| 4683 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 4684 | } |
| 4685 | |
| 4686 | alc_auto_parse_customize_define(codec); |
| 4687 | |
| 4688 | if (board_config == ALC_MODEL_AUTO) { |
| 4689 | /* automatic parse from the BIOS config */ |
| 4690 | err = alc882_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4691 | if (err < 0) |
| 4692 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4693 | } |
| 4694 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 4695 | if (board_config != ALC_MODEL_AUTO) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4696 | setup_preset(codec, &alc882_presets[board_config]); |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 4697 | spec->vmaster_nid = 0x0c; |
| 4698 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4699 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4700 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4701 | alc_auto_fill_adc_caps(codec); |
| 4702 | alc_rebuild_imux_for_auto_mic(codec); |
| 4703 | alc_remove_invalid_adc_nids(codec); |
| 4704 | } |
| 4705 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4706 | if (!spec->no_analog && !spec->cap_mixer) |
| 4707 | set_capture_mixer(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4708 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4709 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 4710 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4711 | if (err < 0) |
| 4712 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4713 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4714 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4715 | |
| 4716 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4717 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4718 | codec->patch_ops = alc_patch_ops; |
| 4719 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4720 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 4721 | else |
| 4722 | codec->patch_ops.build_controls = __alc_build_controls; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4723 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4724 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4725 | if (!spec->loopback.amplist) |
| 4726 | spec->loopback.amplist = alc882_loopbacks; |
| 4727 | #endif |
| 4728 | |
| 4729 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4730 | |
| 4731 | error: |
| 4732 | alc_free(codec); |
| 4733 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4734 | } |
| 4735 | |
| 4736 | |
| 4737 | /* |
| 4738 | * ALC262 support |
| 4739 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4740 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 4741 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4742 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4743 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 4744 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4745 | } |
| 4746 | |
| 4747 | /* |
| 4748 | * Pin config fixes |
| 4749 | */ |
| 4750 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 4751 | ALC262_FIXUP_FSC_H270, |
| 4752 | ALC262_FIXUP_HP_Z200, |
| 4753 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 4754 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 4755 | ALC262_FIXUP_BENQ, |
| 4756 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4757 | }; |
| 4758 | |
| 4759 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 4760 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4761 | .type = ALC_FIXUP_PINS, |
| 4762 | .v.pins = (const struct alc_pincfg[]) { |
| 4763 | { 0x14, 0x99130110 }, /* speaker */ |
| 4764 | { 0x15, 0x0221142f }, /* front HP */ |
| 4765 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 4766 | { } |
| 4767 | } |
| 4768 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 4769 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4770 | .type = ALC_FIXUP_PINS, |
| 4771 | .v.pins = (const struct alc_pincfg[]) { |
| 4772 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 4773 | { } |
| 4774 | } |
| 4775 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 4776 | [ALC262_FIXUP_TYAN] = { |
| 4777 | .type = ALC_FIXUP_PINS, |
| 4778 | .v.pins = (const struct alc_pincfg[]) { |
| 4779 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 4780 | { } |
| 4781 | } |
| 4782 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 4783 | [ALC262_FIXUP_LENOVO_3000] = { |
| 4784 | .type = ALC_FIXUP_VERBS, |
| 4785 | .v.verbs = (const struct hda_verb[]) { |
| 4786 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 4787 | {} |
| 4788 | }, |
| 4789 | .chained = true, |
| 4790 | .chain_id = ALC262_FIXUP_BENQ, |
| 4791 | }, |
| 4792 | [ALC262_FIXUP_BENQ] = { |
| 4793 | .type = ALC_FIXUP_VERBS, |
| 4794 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 4795 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4796 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4797 | {} |
| 4798 | } |
| 4799 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 4800 | [ALC262_FIXUP_BENQ_T31] = { |
| 4801 | .type = ALC_FIXUP_VERBS, |
| 4802 | .v.verbs = (const struct hda_verb[]) { |
| 4803 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4804 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4805 | {} |
| 4806 | } |
| 4807 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4808 | }; |
| 4809 | |
| 4810 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 4811 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 4812 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 4813 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 4814 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 4815 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 4816 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 4817 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 4818 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4819 | {} |
| 4820 | }; |
| 4821 | |
| 4822 | |
| 4823 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4824 | #define alc262_loopbacks alc880_loopbacks |
| 4825 | #endif |
| 4826 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4827 | /* |
| 4828 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4829 | static int patch_alc262(struct hda_codec *codec) |
| 4830 | { |
| 4831 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4832 | int err; |
| 4833 | |
| 4834 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4835 | if (spec == NULL) |
| 4836 | return -ENOMEM; |
| 4837 | |
| 4838 | codec->spec = spec; |
| 4839 | |
| 4840 | spec->mixer_nid = 0x0b; |
| 4841 | |
| 4842 | #if 0 |
| 4843 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 4844 | * under-run |
| 4845 | */ |
| 4846 | { |
| 4847 | int tmp; |
| 4848 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 4849 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 4850 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 4851 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 4852 | } |
| 4853 | #endif |
| 4854 | alc_auto_parse_customize_define(codec); |
| 4855 | |
| 4856 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 4857 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 4858 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 4859 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4860 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 4861 | /* automatic parse from the BIOS config */ |
| 4862 | err = alc262_parse_auto_config(codec); |
| 4863 | if (err < 0) |
| 4864 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4865 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4866 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4867 | alc_auto_fill_adc_caps(codec); |
| 4868 | alc_rebuild_imux_for_auto_mic(codec); |
| 4869 | alc_remove_invalid_adc_nids(codec); |
| 4870 | } |
| 4871 | |
| 4872 | if (!spec->no_analog && !spec->cap_mixer) |
| 4873 | set_capture_mixer(codec); |
| 4874 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4875 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 4876 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4877 | if (err < 0) |
| 4878 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4879 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4880 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4881 | |
| 4882 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4883 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4884 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 4885 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4886 | spec->shutup = alc_eapd_shutup; |
| 4887 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4888 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4889 | if (!spec->loopback.amplist) |
| 4890 | spec->loopback.amplist = alc262_loopbacks; |
| 4891 | #endif |
| 4892 | |
| 4893 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4894 | |
| 4895 | error: |
| 4896 | alc_free(codec); |
| 4897 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4898 | } |
| 4899 | |
| 4900 | /* |
| 4901 | * ALC268 |
| 4902 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4903 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 4904 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 4905 | .ops = &snd_hda_bind_sw, |
| 4906 | .values = { |
| 4907 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 4908 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 4909 | 0 |
| 4910 | }, |
| 4911 | }; |
| 4912 | |
| 4913 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 4914 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 4915 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 4916 | { } |
| 4917 | }; |
| 4918 | |
| 4919 | /* set PCBEEP vol = 0, mute connections */ |
| 4920 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 4921 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4922 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4923 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4924 | { } |
| 4925 | }; |
| 4926 | |
| 4927 | /* |
| 4928 | * BIOS auto configuration |
| 4929 | */ |
| 4930 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 4931 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4932 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4933 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4934 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 4935 | if (err > 0) { |
| 4936 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 4937 | add_mixer(spec, alc268_beep_mixer); |
| 4938 | add_verb(spec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4939 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4940 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4941 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4942 | } |
| 4943 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4944 | /* |
| 4945 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4946 | static int patch_alc268(struct hda_codec *codec) |
| 4947 | { |
| 4948 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4949 | int i, has_beep, err; |
| 4950 | |
| 4951 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4952 | if (spec == NULL) |
| 4953 | return -ENOMEM; |
| 4954 | |
| 4955 | codec->spec = spec; |
| 4956 | |
| 4957 | /* ALC268 has no aa-loopback mixer */ |
| 4958 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 4959 | /* automatic parse from the BIOS config */ |
| 4960 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4961 | if (err < 0) |
| 4962 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4963 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4964 | has_beep = 0; |
| 4965 | for (i = 0; i < spec->num_mixers; i++) { |
| 4966 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 4967 | has_beep = 1; |
| 4968 | break; |
| 4969 | } |
| 4970 | } |
| 4971 | |
| 4972 | if (has_beep) { |
| 4973 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4974 | if (err < 0) |
| 4975 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4976 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 4977 | /* override the amp caps for beep generator */ |
| 4978 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 4979 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 4980 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4981 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4982 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 4983 | } |
| 4984 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4985 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4986 | alc_auto_fill_adc_caps(codec); |
| 4987 | alc_rebuild_imux_for_auto_mic(codec); |
| 4988 | alc_remove_invalid_adc_nids(codec); |
| 4989 | } |
| 4990 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4991 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4992 | set_capture_mixer(codec); |
| 4993 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4994 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 4995 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4996 | spec->shutup = alc_eapd_shutup; |
| 4997 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4998 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4999 | |
| 5000 | error: |
| 5001 | alc_free(codec); |
| 5002 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5003 | } |
| 5004 | |
| 5005 | /* |
| 5006 | * ALC269 |
| 5007 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5008 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5009 | #define alc269_loopbacks alc880_loopbacks |
| 5010 | #endif |
| 5011 | |
| 5012 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5013 | .substreams = 1, |
| 5014 | .channels_min = 2, |
| 5015 | .channels_max = 8, |
| 5016 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5017 | /* NID is set in alc_build_pcms */ |
| 5018 | .ops = { |
| 5019 | .open = alc_playback_pcm_open, |
| 5020 | .prepare = alc_playback_pcm_prepare, |
| 5021 | .cleanup = alc_playback_pcm_cleanup |
| 5022 | }, |
| 5023 | }; |
| 5024 | |
| 5025 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5026 | .substreams = 1, |
| 5027 | .channels_min = 2, |
| 5028 | .channels_max = 2, |
| 5029 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5030 | /* NID is set in alc_build_pcms */ |
| 5031 | }; |
| 5032 | |
| 5033 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5034 | static int alc269_mic2_for_mute_led(struct hda_codec *codec) |
| 5035 | { |
| 5036 | switch (codec->subsystem_id) { |
| 5037 | case 0x103c1586: |
| 5038 | return 1; |
| 5039 | } |
| 5040 | return 0; |
| 5041 | } |
| 5042 | |
| 5043 | static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid) |
| 5044 | { |
| 5045 | /* update mute-LED according to the speaker mute state */ |
| 5046 | if (nid == 0x01 || nid == 0x14) { |
| 5047 | int pinval; |
| 5048 | if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) & |
| 5049 | HDA_AMP_MUTE) |
| 5050 | pinval = 0x24; |
| 5051 | else |
| 5052 | pinval = 0x20; |
| 5053 | /* mic2 vref pin is used for mute LED control */ |
| 5054 | snd_hda_codec_update_cache(codec, 0x19, 0, |
| 5055 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 5056 | pinval); |
| 5057 | } |
| 5058 | return alc_check_power_status(codec, nid); |
| 5059 | } |
| 5060 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ |
| 5061 | |
| 5062 | /* different alc269-variants */ |
| 5063 | enum { |
| 5064 | ALC269_TYPE_ALC269VA, |
| 5065 | ALC269_TYPE_ALC269VB, |
| 5066 | ALC269_TYPE_ALC269VC, |
| 5067 | }; |
| 5068 | |
| 5069 | /* |
| 5070 | * BIOS auto configuration |
| 5071 | */ |
| 5072 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5073 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5074 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5075 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5076 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5077 | struct alc_spec *spec = codec->spec; |
| 5078 | const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? |
| 5079 | alc269va_ssids : alc269_ssids; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5080 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5081 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5082 | } |
| 5083 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5084 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 5085 | { |
| 5086 | int val = alc_read_coef_idx(codec, 0x04); |
| 5087 | if (power_up) |
| 5088 | val |= 1 << 11; |
| 5089 | else |
| 5090 | val &= ~(1 << 11); |
| 5091 | alc_write_coef_idx(codec, 0x04, val); |
| 5092 | } |
| 5093 | |
| 5094 | static void alc269_shutup(struct hda_codec *codec) |
| 5095 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5096 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5097 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5098 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5099 | alc269_toggle_power_output(codec, 0); |
| 5100 | msleep(150); |
| 5101 | } |
| 5102 | } |
| 5103 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5104 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5105 | static int alc269_resume(struct hda_codec *codec) |
| 5106 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5107 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5108 | alc269_toggle_power_output(codec, 0); |
| 5109 | msleep(150); |
| 5110 | } |
| 5111 | |
| 5112 | codec->patch_ops.init(codec); |
| 5113 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5114 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5115 | alc269_toggle_power_output(codec, 1); |
| 5116 | msleep(200); |
| 5117 | } |
| 5118 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5119 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5120 | alc269_toggle_power_output(codec, 1); |
| 5121 | |
| 5122 | snd_hda_codec_resume_amp(codec); |
| 5123 | snd_hda_codec_resume_cache(codec); |
| 5124 | hda_call_check_power_status(codec, 0x01); |
| 5125 | return 0; |
| 5126 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5127 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5128 | |
| 5129 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5130 | const struct alc_fixup *fix, int action) |
| 5131 | { |
| 5132 | int coef; |
| 5133 | |
| 5134 | if (action != ALC_FIXUP_ACT_INIT) |
| 5135 | return; |
| 5136 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5137 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5138 | } |
| 5139 | |
| 5140 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5141 | const struct alc_fixup *fix, int action) |
| 5142 | { |
| 5143 | static const struct hda_verb verbs[] = { |
| 5144 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5145 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5146 | {} |
| 5147 | }; |
| 5148 | unsigned int cfg; |
| 5149 | |
| 5150 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5151 | return; |
| 5152 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5153 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5154 | snd_hda_sequence_write(codec, verbs); |
| 5155 | } |
| 5156 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5157 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5158 | const struct alc_fixup *fix, int action) |
| 5159 | { |
| 5160 | struct alc_spec *spec = codec->spec; |
| 5161 | |
| 5162 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5163 | return; |
| 5164 | |
| 5165 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5166 | * fix the sample rate of analog I/O to 44.1kHz |
| 5167 | */ |
| 5168 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5169 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5170 | } |
| 5171 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5172 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 5173 | const struct alc_fixup *fix, int action) |
| 5174 | { |
| 5175 | int coef; |
| 5176 | |
| 5177 | if (action != ALC_FIXUP_ACT_INIT) |
| 5178 | return; |
| 5179 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5180 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 5181 | * Below is a workaround specific to ALC269 to control the dmic |
| 5182 | * signal source as mono. |
| 5183 | */ |
| 5184 | coef = alc_read_coef_idx(codec, 0x07); |
| 5185 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 5186 | } |
| 5187 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5188 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 5189 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 5190 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5191 | |
| 5192 | snd_hda_codec_write(codec, 0x20, 0, |
| 5193 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5194 | snd_hda_codec_write(codec, 0x20, 0, |
| 5195 | AC_VERB_SET_PROC_COEF, 0x680); |
| 5196 | |
| 5197 | snd_hda_codec_write(codec, 0x20, 0, |
| 5198 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5199 | snd_hda_codec_write(codec, 0x20, 0, |
| 5200 | AC_VERB_SET_PROC_COEF, 0x480); |
| 5201 | } |
| 5202 | |
| 5203 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 5204 | const struct alc_fixup *fix, int action) |
| 5205 | { |
| 5206 | struct alc_spec *spec = codec->spec; |
| 5207 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5208 | return; |
| 5209 | spec->automute_hook = alc269_quanta_automute; |
| 5210 | } |
| 5211 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5212 | enum { |
| 5213 | ALC269_FIXUP_SONY_VAIO, |
| 5214 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 5215 | ALC269_FIXUP_DELL_M101Z, |
| 5216 | ALC269_FIXUP_SKU_IGNORE, |
| 5217 | ALC269_FIXUP_ASUS_G73JW, |
| 5218 | ALC269_FIXUP_LENOVO_EAPD, |
| 5219 | ALC275_FIXUP_SONY_HWEQ, |
| 5220 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5221 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5222 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5223 | ALC269_FIXUP_QUANTA_MUTE, |
| 5224 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5225 | ALC269_FIXUP_AMIC, |
| 5226 | ALC269_FIXUP_DMIC, |
| 5227 | ALC269VB_FIXUP_AMIC, |
| 5228 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5229 | }; |
| 5230 | |
| 5231 | static const struct alc_fixup alc269_fixups[] = { |
| 5232 | [ALC269_FIXUP_SONY_VAIO] = { |
| 5233 | .type = ALC_FIXUP_VERBS, |
| 5234 | .v.verbs = (const struct hda_verb[]) { |
| 5235 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 5236 | {} |
| 5237 | } |
| 5238 | }, |
| 5239 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 5240 | .type = ALC_FIXUP_VERBS, |
| 5241 | .v.verbs = (const struct hda_verb[]) { |
| 5242 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 5243 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 5244 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 5245 | { } |
| 5246 | }, |
| 5247 | .chained = true, |
| 5248 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 5249 | }, |
| 5250 | [ALC269_FIXUP_DELL_M101Z] = { |
| 5251 | .type = ALC_FIXUP_VERBS, |
| 5252 | .v.verbs = (const struct hda_verb[]) { |
| 5253 | /* Enables internal speaker */ |
| 5254 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 5255 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 5256 | {} |
| 5257 | } |
| 5258 | }, |
| 5259 | [ALC269_FIXUP_SKU_IGNORE] = { |
| 5260 | .type = ALC_FIXUP_SKU, |
| 5261 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 5262 | }, |
| 5263 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 5264 | .type = ALC_FIXUP_PINS, |
| 5265 | .v.pins = (const struct alc_pincfg[]) { |
| 5266 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 5267 | { } |
| 5268 | } |
| 5269 | }, |
| 5270 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 5271 | .type = ALC_FIXUP_VERBS, |
| 5272 | .v.verbs = (const struct hda_verb[]) { |
| 5273 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5274 | {} |
| 5275 | } |
| 5276 | }, |
| 5277 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 5278 | .type = ALC_FIXUP_FUNC, |
| 5279 | .v.func = alc269_fixup_hweq, |
| 5280 | .chained = true, |
| 5281 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 5282 | }, |
| 5283 | [ALC271_FIXUP_DMIC] = { |
| 5284 | .type = ALC_FIXUP_FUNC, |
| 5285 | .v.func = alc271_fixup_dmic, |
| 5286 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5287 | [ALC269_FIXUP_PCM_44K] = { |
| 5288 | .type = ALC_FIXUP_FUNC, |
| 5289 | .v.func = alc269_fixup_pcm_44k, |
| 5290 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5291 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 5292 | .type = ALC_FIXUP_FUNC, |
| 5293 | .v.func = alc269_fixup_stereo_dmic, |
| 5294 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5295 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 5296 | .type = ALC_FIXUP_FUNC, |
| 5297 | .v.func = alc269_fixup_quanta_mute, |
| 5298 | }, |
| 5299 | [ALC269_FIXUP_LIFEBOOK] = { |
| 5300 | .type = ALC_FIXUP_PINS, |
| 5301 | .v.pins = (const struct alc_pincfg[]) { |
| 5302 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 5303 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 5304 | { } |
| 5305 | }, |
| 5306 | .chained = true, |
| 5307 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 5308 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5309 | [ALC269_FIXUP_AMIC] = { |
| 5310 | .type = ALC_FIXUP_PINS, |
| 5311 | .v.pins = (const struct alc_pincfg[]) { |
| 5312 | { 0x14, 0x99130110 }, /* speaker */ |
| 5313 | { 0x15, 0x0121401f }, /* HP out */ |
| 5314 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5315 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5316 | { } |
| 5317 | }, |
| 5318 | }, |
| 5319 | [ALC269_FIXUP_DMIC] = { |
| 5320 | .type = ALC_FIXUP_PINS, |
| 5321 | .v.pins = (const struct alc_pincfg[]) { |
| 5322 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 5323 | { 0x14, 0x99130110 }, /* speaker */ |
| 5324 | { 0x15, 0x0121401f }, /* HP out */ |
| 5325 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5326 | { } |
| 5327 | }, |
| 5328 | }, |
| 5329 | [ALC269VB_FIXUP_AMIC] = { |
| 5330 | .type = ALC_FIXUP_PINS, |
| 5331 | .v.pins = (const struct alc_pincfg[]) { |
| 5332 | { 0x14, 0x99130110 }, /* speaker */ |
| 5333 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5334 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5335 | { 0x21, 0x0121401f }, /* HP out */ |
| 5336 | { } |
| 5337 | }, |
| 5338 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 5339 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5340 | .type = ALC_FIXUP_PINS, |
| 5341 | .v.pins = (const struct alc_pincfg[]) { |
| 5342 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 5343 | { 0x14, 0x99130110 }, /* speaker */ |
| 5344 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5345 | { 0x21, 0x0121401f }, /* HP out */ |
| 5346 | { } |
| 5347 | }, |
| 5348 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5349 | }; |
| 5350 | |
| 5351 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5352 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5353 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 5354 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 5355 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 5356 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 5357 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5358 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 5359 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 5360 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 5361 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 5362 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 5363 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5364 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5365 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 5366 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 5367 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 5368 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 5369 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5370 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5371 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5372 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5373 | |
| 5374 | #if 1 |
| 5375 | /* Below is a quirk table taken from the old code. |
| 5376 | * Basically the device should work as is without the fixup table. |
| 5377 | * If BIOS doesn't give a proper info, enable the corresponding |
| 5378 | * fixup entry. |
| 5379 | */ |
| 5380 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 5381 | ALC269_FIXUP_AMIC), |
| 5382 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5383 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 5384 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 5385 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 5386 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 5387 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 5388 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 5389 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 5390 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 5391 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 5392 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 5393 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 5394 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 5395 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 5396 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 5397 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 5398 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 5399 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 5400 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 5401 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 5402 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 5403 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 5404 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 5405 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 5406 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 5407 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 5408 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 5409 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 5410 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 5411 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 5412 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 5413 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 5414 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 5415 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 5416 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 5417 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 5418 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 5419 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 5420 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 5421 | #endif |
| 5422 | {} |
| 5423 | }; |
| 5424 | |
| 5425 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 5426 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 5427 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5428 | {} |
| 5429 | }; |
| 5430 | |
| 5431 | |
| 5432 | static int alc269_fill_coef(struct hda_codec *codec) |
| 5433 | { |
| 5434 | int val; |
| 5435 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5436 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5437 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 5438 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 5439 | } |
| 5440 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5441 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5442 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 5443 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 5444 | } |
| 5445 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5446 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5447 | val = alc_read_coef_idx(codec, 0x04); |
| 5448 | /* Power up output pin */ |
| 5449 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 5450 | } |
| 5451 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5452 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5453 | val = alc_read_coef_idx(codec, 0xd); |
| 5454 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 5455 | /* Capless ramp up clock control */ |
| 5456 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 5457 | } |
| 5458 | val = alc_read_coef_idx(codec, 0x17); |
| 5459 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 5460 | /* Class D power on reset */ |
| 5461 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 5462 | } |
| 5463 | } |
| 5464 | |
| 5465 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 5466 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 5467 | |
| 5468 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 5469 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
| 5470 | |
| 5471 | return 0; |
| 5472 | } |
| 5473 | |
| 5474 | /* |
| 5475 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5476 | static int patch_alc269(struct hda_codec *codec) |
| 5477 | { |
| 5478 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5479 | int err = 0; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5480 | |
| 5481 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5482 | if (spec == NULL) |
| 5483 | return -ENOMEM; |
| 5484 | |
| 5485 | codec->spec = spec; |
| 5486 | |
| 5487 | spec->mixer_nid = 0x0b; |
| 5488 | |
| 5489 | alc_auto_parse_customize_define(codec); |
| 5490 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5491 | err = alc_codec_rename_from_preset(codec); |
| 5492 | if (err < 0) |
| 5493 | goto error; |
| 5494 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5495 | if (codec->vendor_id == 0x10ec0269) { |
| 5496 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5497 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 5498 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5499 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5500 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5501 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5502 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5503 | break; |
| 5504 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5505 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 5506 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5507 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5508 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5509 | break; |
| 5510 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5511 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5512 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5513 | if (err < 0) |
| 5514 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5515 | alc269_fill_coef(codec); |
| 5516 | } |
| 5517 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5518 | alc_pick_fixup(codec, alc269_fixup_models, |
| 5519 | alc269_fixup_tbl, alc269_fixups); |
| 5520 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5521 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5522 | /* automatic parse from the BIOS config */ |
| 5523 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5524 | if (err < 0) |
| 5525 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5526 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5527 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5528 | alc_auto_fill_adc_caps(codec); |
| 5529 | alc_rebuild_imux_for_auto_mic(codec); |
| 5530 | alc_remove_invalid_adc_nids(codec); |
| 5531 | } |
| 5532 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5533 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5534 | set_capture_mixer(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5535 | |
| 5536 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5537 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5538 | if (err < 0) |
| 5539 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5540 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5541 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5542 | |
| 5543 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5544 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5545 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5546 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5547 | codec->patch_ops.resume = alc269_resume; |
| 5548 | #endif |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5549 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5550 | spec->shutup = alc269_shutup; |
| 5551 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5552 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5553 | if (!spec->loopback.amplist) |
| 5554 | spec->loopback.amplist = alc269_loopbacks; |
| 5555 | if (alc269_mic2_for_mute_led(codec)) |
| 5556 | codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps; |
| 5557 | #endif |
| 5558 | |
| 5559 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5560 | |
| 5561 | error: |
| 5562 | alc_free(codec); |
| 5563 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5564 | } |
| 5565 | |
| 5566 | /* |
| 5567 | * ALC861 |
| 5568 | */ |
| 5569 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5570 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 5571 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5572 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5573 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 5574 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5575 | } |
| 5576 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5577 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5578 | static const struct hda_amp_list alc861_loopbacks[] = { |
| 5579 | { 0x15, HDA_INPUT, 0 }, |
| 5580 | { 0x15, HDA_INPUT, 1 }, |
| 5581 | { 0x15, HDA_INPUT, 2 }, |
| 5582 | { 0x15, HDA_INPUT, 3 }, |
| 5583 | { } /* end */ |
| 5584 | }; |
| 5585 | #endif |
| 5586 | |
| 5587 | |
| 5588 | /* Pin config fixes */ |
| 5589 | enum { |
| 5590 | PINFIX_FSC_AMILO_PI1505, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 5591 | PINFIX_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5592 | }; |
| 5593 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 5594 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 5595 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 5596 | const struct alc_fixup *fix, int action) |
| 5597 | { |
| 5598 | struct alc_spec *spec = codec->spec; |
| 5599 | unsigned int val; |
| 5600 | |
| 5601 | if (action != ALC_FIXUP_ACT_INIT) |
| 5602 | return; |
| 5603 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 5604 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5605 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 5606 | val |= AC_PINCTL_IN_EN; |
| 5607 | val |= AC_PINCTL_VREF_50; |
| 5608 | snd_hda_codec_write(codec, 0x0f, 0, |
| 5609 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5610 | spec->keep_vref_in_automute = 1; |
| 5611 | } |
| 5612 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5613 | static const struct alc_fixup alc861_fixups[] = { |
| 5614 | [PINFIX_FSC_AMILO_PI1505] = { |
| 5615 | .type = ALC_FIXUP_PINS, |
| 5616 | .v.pins = (const struct alc_pincfg[]) { |
| 5617 | { 0x0b, 0x0221101f }, /* HP */ |
| 5618 | { 0x0f, 0x90170310 }, /* speaker */ |
| 5619 | { } |
| 5620 | } |
| 5621 | }, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 5622 | [PINFIX_ASUS_A6RP] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 5623 | .type = ALC_FIXUP_FUNC, |
| 5624 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 5625 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5626 | }; |
| 5627 | |
| 5628 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 5629 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", PINFIX_ASUS_A6RP), |
Takashi Iwai | b3a8152 | 2012-01-26 15:56:16 +0100 | [diff] [blame] | 5630 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", PINFIX_ASUS_A6RP), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5631 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505), |
| 5632 | {} |
| 5633 | }; |
| 5634 | |
| 5635 | /* |
| 5636 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5637 | static int patch_alc861(struct hda_codec *codec) |
| 5638 | { |
| 5639 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5640 | int err; |
| 5641 | |
| 5642 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5643 | if (spec == NULL) |
| 5644 | return -ENOMEM; |
| 5645 | |
| 5646 | codec->spec = spec; |
| 5647 | |
| 5648 | spec->mixer_nid = 0x15; |
| 5649 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5650 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 5651 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5652 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5653 | /* automatic parse from the BIOS config */ |
| 5654 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5655 | if (err < 0) |
| 5656 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5657 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5658 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5659 | alc_auto_fill_adc_caps(codec); |
| 5660 | alc_rebuild_imux_for_auto_mic(codec); |
| 5661 | alc_remove_invalid_adc_nids(codec); |
| 5662 | } |
| 5663 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5664 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5665 | set_capture_mixer(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5666 | |
| 5667 | if (!spec->no_analog) { |
| 5668 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5669 | if (err < 0) |
| 5670 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5671 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 5672 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5673 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5674 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5675 | |
| 5676 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5677 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5678 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5679 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5680 | if (!spec->loopback.amplist) |
| 5681 | spec->loopback.amplist = alc861_loopbacks; |
| 5682 | #endif |
| 5683 | |
| 5684 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5685 | |
| 5686 | error: |
| 5687 | alc_free(codec); |
| 5688 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5689 | } |
| 5690 | |
| 5691 | /* |
| 5692 | * ALC861-VD support |
| 5693 | * |
| 5694 | * Based on ALC882 |
| 5695 | * |
| 5696 | * In addition, an independent DAC |
| 5697 | */ |
| 5698 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5699 | #define alc861vd_loopbacks alc880_loopbacks |
| 5700 | #endif |
| 5701 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5702 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 5703 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5704 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5705 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5706 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5707 | } |
| 5708 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5709 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5710 | ALC660VD_FIX_ASUS_GPIO1, |
| 5711 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5712 | }; |
| 5713 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5714 | /* exclude VREF80 */ |
| 5715 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 5716 | const struct alc_fixup *fix, int action) |
| 5717 | { |
| 5718 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 5719 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 5720 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 5721 | } |
| 5722 | } |
| 5723 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5724 | static const struct alc_fixup alc861vd_fixups[] = { |
| 5725 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 5726 | .type = ALC_FIXUP_VERBS, |
| 5727 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5728 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5729 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 5730 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 5731 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 5732 | { } |
| 5733 | } |
| 5734 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5735 | [ALC861VD_FIX_DALLAS] = { |
| 5736 | .type = ALC_FIXUP_FUNC, |
| 5737 | .v.func = alc861vd_fixup_dallas, |
| 5738 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5739 | }; |
| 5740 | |
| 5741 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5742 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5743 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5744 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5745 | {} |
| 5746 | }; |
| 5747 | |
| 5748 | static const struct hda_verb alc660vd_eapd_verbs[] = { |
| 5749 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 5750 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 5751 | { } |
| 5752 | }; |
| 5753 | |
| 5754 | /* |
| 5755 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5756 | static int patch_alc861vd(struct hda_codec *codec) |
| 5757 | { |
| 5758 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5759 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5760 | |
| 5761 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5762 | if (spec == NULL) |
| 5763 | return -ENOMEM; |
| 5764 | |
| 5765 | codec->spec = spec; |
| 5766 | |
| 5767 | spec->mixer_nid = 0x0b; |
| 5768 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5769 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 5770 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5771 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5772 | /* automatic parse from the BIOS config */ |
| 5773 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5774 | if (err < 0) |
| 5775 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5776 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5777 | if (codec->vendor_id == 0x10ec0660) { |
| 5778 | /* always turn on EAPD */ |
| 5779 | add_verb(spec, alc660vd_eapd_verbs); |
| 5780 | } |
| 5781 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5782 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5783 | alc_auto_fill_adc_caps(codec); |
| 5784 | alc_rebuild_imux_for_auto_mic(codec); |
| 5785 | alc_remove_invalid_adc_nids(codec); |
| 5786 | } |
| 5787 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5788 | if (!spec->no_analog && !spec->cap_mixer) |
| 5789 | set_capture_mixer(codec); |
| 5790 | |
| 5791 | if (!spec->no_analog) { |
| 5792 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5793 | if (err < 0) |
| 5794 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5795 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 5796 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5797 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5798 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5799 | |
| 5800 | codec->patch_ops = alc_patch_ops; |
| 5801 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5802 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5803 | spec->shutup = alc_eapd_shutup; |
| 5804 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5805 | if (!spec->loopback.amplist) |
| 5806 | spec->loopback.amplist = alc861vd_loopbacks; |
| 5807 | #endif |
| 5808 | |
| 5809 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5810 | |
| 5811 | error: |
| 5812 | alc_free(codec); |
| 5813 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5814 | } |
| 5815 | |
| 5816 | /* |
| 5817 | * ALC662 support |
| 5818 | * |
| 5819 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 5820 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5821 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5822 | * 6-channel independent captures. |
| 5823 | * |
| 5824 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5825 | * driver yet). |
| 5826 | */ |
| 5827 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5828 | #define alc662_loopbacks alc880_loopbacks |
| 5829 | #endif |
| 5830 | |
| 5831 | /* |
| 5832 | * BIOS auto configuration |
| 5833 | */ |
| 5834 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5835 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 5836 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 5837 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5838 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 5839 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5840 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 5841 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 5842 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 5843 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5844 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 5845 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5846 | ssids = alc662_ssids; |
| 5847 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5848 | } |
| 5849 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5850 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5851 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 5852 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5853 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 5854 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5855 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 5856 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 5857 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5858 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5859 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 5860 | printk(KERN_WARNING |
| 5861 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 5862 | } |
| 5863 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5864 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5865 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5866 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5867 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 5868 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 5869 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 5870 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5871 | ALC662_FIXUP_ASUS_MODE1, |
| 5872 | ALC662_FIXUP_ASUS_MODE2, |
| 5873 | ALC662_FIXUP_ASUS_MODE3, |
| 5874 | ALC662_FIXUP_ASUS_MODE4, |
| 5875 | ALC662_FIXUP_ASUS_MODE5, |
| 5876 | ALC662_FIXUP_ASUS_MODE6, |
| 5877 | ALC662_FIXUP_ASUS_MODE7, |
| 5878 | ALC662_FIXUP_ASUS_MODE8, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5879 | }; |
| 5880 | |
| 5881 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5882 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5883 | .type = ALC_FIXUP_PINS, |
| 5884 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5885 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 5886 | { } |
| 5887 | } |
| 5888 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5889 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5890 | .type = ALC_FIXUP_PINS, |
| 5891 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5892 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 5893 | { } |
| 5894 | } |
| 5895 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5896 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5897 | .type = ALC_FIXUP_FUNC, |
| 5898 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 5899 | }, |
| 5900 | [ALC662_FIXUP_CZC_P10T] = { |
| 5901 | .type = ALC_FIXUP_VERBS, |
| 5902 | .v.verbs = (const struct hda_verb[]) { |
| 5903 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5904 | {} |
| 5905 | } |
| 5906 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 5907 | [ALC662_FIXUP_SKU_IGNORE] = { |
| 5908 | .type = ALC_FIXUP_SKU, |
| 5909 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 5910 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 5911 | [ALC662_FIXUP_HP_RP5800] = { |
| 5912 | .type = ALC_FIXUP_PINS, |
| 5913 | .v.pins = (const struct alc_pincfg[]) { |
| 5914 | { 0x14, 0x0221201f }, /* HP out */ |
| 5915 | { } |
| 5916 | }, |
| 5917 | .chained = true, |
| 5918 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5919 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5920 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 5921 | .type = ALC_FIXUP_PINS, |
| 5922 | .v.pins = (const struct alc_pincfg[]) { |
| 5923 | { 0x14, 0x99130110 }, /* speaker */ |
| 5924 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5925 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5926 | { 0x21, 0x0121401f }, /* HP out */ |
| 5927 | { } |
| 5928 | }, |
| 5929 | .chained = true, |
| 5930 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5931 | }, |
| 5932 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 5933 | .type = ALC_FIXUP_PINS, |
| 5934 | .v.pins = (const struct alc_pincfg[]) { |
| 5935 | { 0x14, 0x99130110 }, /* speaker */ |
| 5936 | { 0x18, 0x01a19820 }, /* mic */ |
| 5937 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5938 | { 0x1b, 0x0121401f }, /* HP out */ |
| 5939 | { } |
| 5940 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5941 | .chained = true, |
| 5942 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5943 | }, |
| 5944 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 5945 | .type = ALC_FIXUP_PINS, |
| 5946 | .v.pins = (const struct alc_pincfg[]) { |
| 5947 | { 0x14, 0x99130110 }, /* speaker */ |
| 5948 | { 0x15, 0x0121441f }, /* HP */ |
| 5949 | { 0x18, 0x01a19840 }, /* mic */ |
| 5950 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5951 | { 0x21, 0x01211420 }, /* HP2 */ |
| 5952 | { } |
| 5953 | }, |
| 5954 | .chained = true, |
| 5955 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5956 | }, |
| 5957 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 5958 | .type = ALC_FIXUP_PINS, |
| 5959 | .v.pins = (const struct alc_pincfg[]) { |
| 5960 | { 0x14, 0x99130110 }, /* speaker */ |
| 5961 | { 0x16, 0x99130111 }, /* speaker */ |
| 5962 | { 0x18, 0x01a19840 }, /* mic */ |
| 5963 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5964 | { 0x21, 0x0121441f }, /* HP */ |
| 5965 | { } |
| 5966 | }, |
| 5967 | .chained = true, |
| 5968 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5969 | }, |
| 5970 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 5971 | .type = ALC_FIXUP_PINS, |
| 5972 | .v.pins = (const struct alc_pincfg[]) { |
| 5973 | { 0x14, 0x99130110 }, /* speaker */ |
| 5974 | { 0x15, 0x0121441f }, /* HP */ |
| 5975 | { 0x16, 0x99130111 }, /* speaker */ |
| 5976 | { 0x18, 0x01a19840 }, /* mic */ |
| 5977 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5978 | { } |
| 5979 | }, |
| 5980 | .chained = true, |
| 5981 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5982 | }, |
| 5983 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 5984 | .type = ALC_FIXUP_PINS, |
| 5985 | .v.pins = (const struct alc_pincfg[]) { |
| 5986 | { 0x14, 0x99130110 }, /* speaker */ |
| 5987 | { 0x15, 0x01211420 }, /* HP2 */ |
| 5988 | { 0x18, 0x01a19840 }, /* mic */ |
| 5989 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5990 | { 0x1b, 0x0121441f }, /* HP */ |
| 5991 | { } |
| 5992 | }, |
| 5993 | .chained = true, |
| 5994 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5995 | }, |
| 5996 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 5997 | .type = ALC_FIXUP_PINS, |
| 5998 | .v.pins = (const struct alc_pincfg[]) { |
| 5999 | { 0x14, 0x99130110 }, /* speaker */ |
| 6000 | { 0x17, 0x99130111 }, /* speaker */ |
| 6001 | { 0x18, 0x01a19840 }, /* mic */ |
| 6002 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6003 | { 0x1b, 0x01214020 }, /* HP */ |
| 6004 | { 0x21, 0x0121401f }, /* HP */ |
| 6005 | { } |
| 6006 | }, |
| 6007 | .chained = true, |
| 6008 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6009 | }, |
| 6010 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6011 | .type = ALC_FIXUP_PINS, |
| 6012 | .v.pins = (const struct alc_pincfg[]) { |
| 6013 | { 0x14, 0x99130110 }, /* speaker */ |
| 6014 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6015 | { 0x15, 0x01214020 }, /* HP */ |
| 6016 | { 0x17, 0x99130111 }, /* speaker */ |
| 6017 | { 0x18, 0x01a19840 }, /* mic */ |
| 6018 | { 0x21, 0x0121401f }, /* HP */ |
| 6019 | { } |
| 6020 | }, |
| 6021 | .chained = true, |
| 6022 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6023 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6024 | }; |
| 6025 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6026 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6027 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6028 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6029 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6030 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6031 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6032 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6033 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6034 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6035 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6036 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6037 | |
| 6038 | #if 0 |
| 6039 | /* Below is a quirk table taken from the old code. |
| 6040 | * Basically the device should work as is without the fixup table. |
| 6041 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6042 | * fixup entry. |
| 6043 | */ |
| 6044 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6045 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6046 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6047 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6048 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6049 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6050 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6051 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6052 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6053 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6054 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6055 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6056 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6057 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6058 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6059 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6060 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6061 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6062 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6063 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6064 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6065 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6066 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6067 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6068 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6069 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6070 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6071 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6072 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6073 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 6074 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6075 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6076 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 6077 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 6078 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 6079 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 6080 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 6081 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 6082 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 6083 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6084 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 6085 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 6086 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6087 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 6088 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 6089 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 6090 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 6091 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 6092 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6093 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 6094 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6095 | {} |
| 6096 | }; |
| 6097 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6098 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 6099 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6100 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 6101 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 6102 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 6103 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 6104 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 6105 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 6106 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 6107 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6108 | {} |
| 6109 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6110 | |
| 6111 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6112 | /* |
| 6113 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6114 | static int patch_alc662(struct hda_codec *codec) |
| 6115 | { |
| 6116 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6117 | int err = 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6118 | |
| 6119 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6120 | if (!spec) |
| 6121 | return -ENOMEM; |
| 6122 | |
| 6123 | codec->spec = spec; |
| 6124 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6125 | spec->mixer_nid = 0x0b; |
| 6126 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6127 | /* handle multiple HPs as is */ |
| 6128 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6129 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6130 | alc_auto_parse_customize_define(codec); |
| 6131 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 6132 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6133 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6134 | err = alc_codec_rename_from_preset(codec); |
| 6135 | if (err < 0) |
| 6136 | goto error; |
| 6137 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6138 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6139 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6140 | spec->cdefine.platform_type == 1) { |
| 6141 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 6142 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6143 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6144 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6145 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6146 | alc662_fixup_tbl, alc662_fixups); |
| 6147 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6148 | /* automatic parse from the BIOS config */ |
| 6149 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6150 | if (err < 0) |
| 6151 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6152 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 6153 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 6154 | alc_auto_fill_adc_caps(codec); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 6155 | alc_rebuild_imux_for_auto_mic(codec); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 6156 | alc_remove_invalid_adc_nids(codec); |
Takashi Iwai | dd70469 | 2009-08-11 08:45:11 +0200 | [diff] [blame] | 6157 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6158 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6159 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | b59bdf3 | 2009-08-11 09:47:30 +0200 | [diff] [blame] | 6160 | set_capture_mixer(codec); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 6161 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6162 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6163 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6164 | if (err < 0) |
| 6165 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6166 | switch (codec->vendor_id) { |
| 6167 | case 0x10ec0662: |
| 6168 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6169 | break; |
| 6170 | case 0x10ec0272: |
| 6171 | case 0x10ec0663: |
| 6172 | case 0x10ec0665: |
| 6173 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 6174 | break; |
| 6175 | case 0x10ec0273: |
| 6176 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 6177 | break; |
| 6178 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6179 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 6180 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6181 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6182 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6183 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6184 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 6185 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6186 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 6187 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 6188 | if (!spec->loopback.amplist) |
| 6189 | spec->loopback.amplist = alc662_loopbacks; |
| 6190 | #endif |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6191 | |
| 6192 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6193 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6194 | error: |
| 6195 | alc_free(codec); |
| 6196 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 6197 | } |
| 6198 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6199 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6200 | * ALC680 support |
| 6201 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6202 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6203 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 6204 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6205 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6206 | } |
| 6207 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6208 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6209 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6210 | static int patch_alc680(struct hda_codec *codec) |
| 6211 | { |
| 6212 | struct alc_spec *spec; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6213 | int err; |
| 6214 | |
| 6215 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6216 | if (spec == NULL) |
| 6217 | return -ENOMEM; |
| 6218 | |
| 6219 | codec->spec = spec; |
| 6220 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6221 | /* ALC680 has no aa-loopback mixer */ |
| 6222 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 6223 | /* automatic parse from the BIOS config */ |
| 6224 | err = alc680_parse_auto_config(codec); |
| 6225 | if (err < 0) { |
| 6226 | alc_free(codec); |
| 6227 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6228 | } |
| 6229 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6230 | if (!spec->no_analog && !spec->cap_mixer) |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6231 | set_capture_mixer(codec); |
| 6232 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6233 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 6234 | spec->init_hook = alc_auto_init_std; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6235 | |
| 6236 | return 0; |
| 6237 | } |
| 6238 | |
| 6239 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6240 | * patch entries |
| 6241 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6242 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6243 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6245 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6246 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 6247 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6248 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6249 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 6250 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6251 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6252 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6253 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6254 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6255 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 6256 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 6257 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6258 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6259 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6260 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 6261 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 6262 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 6263 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 6264 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6265 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6266 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6267 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6268 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6269 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6270 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 6271 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6272 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 6273 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6274 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6275 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6276 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 6277 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6278 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6279 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6280 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6281 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6282 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6283 | {} /* terminator */ |
| 6284 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6285 | |
| 6286 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 6287 | |
| 6288 | MODULE_LICENSE("GPL"); |
| 6289 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 6290 | |
| 6291 | static struct hda_codec_preset_list realtek_list = { |
| 6292 | .preset = snd_hda_preset_realtek, |
| 6293 | .owner = THIS_MODULE, |
| 6294 | }; |
| 6295 | |
| 6296 | static int __init patch_realtek_init(void) |
| 6297 | { |
| 6298 | return snd_hda_add_codec_preset(&realtek_list); |
| 6299 | } |
| 6300 | |
| 6301 | static void __exit patch_realtek_exit(void) |
| 6302 | { |
| 6303 | snd_hda_delete_codec_preset(&realtek_list); |
| 6304 | } |
| 6305 | |
| 6306 | module_init(patch_realtek_init) |
| 6307 | module_exit(patch_realtek_exit) |