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 | 4a79ba3 | 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 | |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 83 | #define MAX_VOL_NIDS 0x40 |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | struct alc_spec { |
| 86 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 87 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 89 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 90 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Takashi Iwai | 2d9c648 | 2009-10-13 08:06:55 +0200 | [diff] [blame] | 92 | const struct hda_verb *init_verbs[10]; /* initialization verbs |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 93 | * don't forget NULL |
| 94 | * termination! |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 95 | */ |
| 96 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 98 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 99 | const struct hda_pcm_stream *stream_analog_playback; |
| 100 | const struct hda_pcm_stream *stream_analog_capture; |
| 101 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 102 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 104 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 105 | const struct hda_pcm_stream *stream_digital_playback; |
| 106 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 109 | struct hda_multi_out multiout; /* playback set-up |
| 110 | * max_channels, dacs must be set |
| 111 | * dig_out_nid and hp_nid are optional |
| 112 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 113 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 114 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 115 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | /* capture */ |
| 118 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 119 | const hda_nid_t *adc_nids; |
| 120 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 121 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 122 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 123 | DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1); |
| 124 | DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 126 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 127 | hda_nid_t cur_adc; |
| 128 | unsigned int cur_adc_stream_tag; |
| 129 | unsigned int cur_adc_format; |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 132 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | const struct hda_input_mux *input_mux; |
| 134 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 135 | hda_nid_t ext_mic_pin; |
| 136 | hda_nid_t dock_mic_pin; |
| 137 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 140 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 142 | int need_dac_fix; |
Hector Martin | 3b315d7 | 2009-06-02 10:54:19 +0200 | [diff] [blame] | 143 | int const_channel_count; |
| 144 | int ext_channel_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 147 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 148 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 149 | /* dynamic controls, init_verbs and input_mux */ |
| 150 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 151 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 152 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 153 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 154 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 155 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 156 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 157 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 158 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 159 | 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] | 160 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 161 | /* hooks */ |
| 162 | void (*init_hook)(struct hda_codec *codec); |
| 163 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 164 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 165 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 166 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 167 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 168 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 169 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 170 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 171 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 172 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 173 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 174 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 175 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 176 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 177 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 178 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 179 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 180 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 181 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 182 | 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] | 183 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 184 | /* other flags */ |
| 185 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 186 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 187 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 188 | 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] | 189 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 190 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 191 | |
| 192 | /* auto-mute control */ |
| 193 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 194 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 195 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 196 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 197 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 198 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 199 | /* for virtual master */ |
| 200 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 201 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 202 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 203 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 204 | int num_loopbacks; |
| 205 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 206 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 207 | |
| 208 | /* for PLL fix */ |
| 209 | hda_nid_t pll_nid; |
| 210 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 211 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 212 | |
| 213 | /* fix-up list */ |
| 214 | int fixup_id; |
| 215 | const struct alc_fixup *fixup_list; |
| 216 | const char *fixup_name; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 217 | |
| 218 | /* multi-io */ |
| 219 | int multi_ios; |
| 220 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 221 | |
| 222 | /* bind volumes */ |
| 223 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 224 | }; |
| 225 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 226 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 227 | int dir, unsigned int bits) |
| 228 | { |
| 229 | if (!nid) |
| 230 | return false; |
| 231 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 232 | if (query_amp_caps(codec, nid, dir) & bits) |
| 233 | return true; |
| 234 | return false; |
| 235 | } |
| 236 | |
| 237 | #define nid_has_mute(codec, nid, dir) \ |
| 238 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 239 | #define nid_has_volume(codec, nid, dir) \ |
| 240 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | /* |
| 243 | * input MUX handling |
| 244 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 245 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 246 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | { |
| 248 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 249 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 250 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 251 | if (mux_idx >= spec->num_mux_defs) |
| 252 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 253 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 254 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 255 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 258 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 259 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | { |
| 261 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 262 | struct alc_spec *spec = codec->spec; |
| 263 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 264 | |
| 265 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 266 | return 0; |
| 267 | } |
| 268 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 269 | 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] | 270 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 271 | struct alc_spec *spec = codec->spec; |
| 272 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 273 | |
| 274 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 275 | /* stream is running, let's swap the current ADC */ |
| 276 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 277 | spec->cur_adc = new_adc; |
| 278 | snd_hda_codec_setup_stream(codec, new_adc, |
| 279 | spec->cur_adc_stream_tag, 0, |
| 280 | spec->cur_adc_format); |
| 281 | return true; |
| 282 | } |
| 283 | return false; |
| 284 | } |
| 285 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 286 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 287 | { |
| 288 | return spec->capsrc_nids ? |
| 289 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 290 | } |
| 291 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 292 | static void call_update_outputs(struct hda_codec *codec); |
| 293 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 294 | /* select the given imux item; either unmute exclusively or select the route */ |
| 295 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 296 | unsigned int idx, bool force) |
| 297 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 299 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 300 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 301 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 302 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Takashi Iwai | 5803a32 | 2012-02-21 11:59:45 +0100 | [diff] [blame] | 304 | if (!spec->input_mux) |
| 305 | return 0; |
| 306 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 307 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 308 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 309 | if (!imux->num_items && mux_idx > 0) |
| 310 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 311 | if (!imux->num_items) |
| 312 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 313 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 314 | if (idx >= imux->num_items) |
| 315 | idx = imux->num_items - 1; |
| 316 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 317 | return 0; |
| 318 | spec->cur_mux[adc_idx] = idx; |
| 319 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 320 | /* for shared I/O, change the pin-control accordingly */ |
| 321 | if (spec->shared_mic_hp) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 322 | unsigned int val; |
| 323 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 324 | /* NOTE: this assumes that there are only two inputs, the |
| 325 | * first is the real internal mic and the second is HP jack. |
| 326 | */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 327 | if (spec->cur_mux[adc_idx]) |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 328 | val = snd_hda_get_default_vref(codec, pin) | PIN_IN; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 329 | else |
| 330 | val = PIN_HP; |
| 331 | snd_hda_set_pin_ctl(codec, pin, val); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 332 | spec->automute_speaker = !spec->cur_mux[adc_idx]; |
| 333 | call_update_outputs(codec); |
| 334 | } |
| 335 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 336 | if (spec->dyn_adc_switch) { |
| 337 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 338 | adc_idx = spec->dyn_adc_idx[idx]; |
| 339 | } |
| 340 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 341 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 342 | |
| 343 | /* no selection? */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 344 | num_conns = snd_hda_get_conn_list(codec, nid, NULL); |
| 345 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 346 | return 1; |
| 347 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 348 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 349 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 350 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 351 | int active = imux->items[idx].index; |
| 352 | for (i = 0; i < num_conns; i++) { |
| 353 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 354 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 355 | HDA_AMP_MUTE, v); |
| 356 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 357 | } else { |
| 358 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 359 | snd_hda_codec_write_cache(codec, nid, 0, |
| 360 | AC_VERB_SET_CONNECT_SEL, |
| 361 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 362 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 363 | return 1; |
| 364 | } |
| 365 | |
| 366 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 367 | struct snd_ctl_elem_value *ucontrol) |
| 368 | { |
| 369 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 370 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 371 | return alc_mux_select(codec, adc_idx, |
| 372 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 373 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 374 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 376 | * set up the input pin config (depending on the given auto-pin type) |
| 377 | */ |
| 378 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 379 | int auto_pin_type) |
| 380 | { |
| 381 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 382 | if (auto_pin_type == AUTO_PIN_MIC) |
| 383 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 384 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 388 | * Append the given mixer and verb elements for the later use |
| 389 | * The mixer array is referred in build_controls(), and init_verbs are |
| 390 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 391 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 392 | 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] | 393 | { |
| 394 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 395 | return; |
| 396 | spec->mixers[spec->num_mixers++] = mix; |
| 397 | } |
| 398 | |
| 399 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) |
| 400 | { |
| 401 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) |
| 402 | return; |
| 403 | spec->init_verbs[spec->num_init_verbs++] = verb; |
| 404 | } |
| 405 | |
| 406 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 407 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 408 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 409 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 410 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 411 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 412 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 413 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 414 | { } |
| 415 | }; |
| 416 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 417 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 418 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 419 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 420 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 421 | { } |
| 422 | }; |
| 423 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 424 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 425 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 426 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 427 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 428 | { } |
| 429 | }; |
| 430 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 431 | /* |
| 432 | * Fix hardware PLL issue |
| 433 | * On some codecs, the analog PLL gating control must be off while |
| 434 | * the default value is 1. |
| 435 | */ |
| 436 | static void alc_fix_pll(struct hda_codec *codec) |
| 437 | { |
| 438 | struct alc_spec *spec = codec->spec; |
| 439 | unsigned int val; |
| 440 | |
| 441 | if (!spec->pll_nid) |
| 442 | return; |
| 443 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 444 | spec->pll_coef_idx); |
| 445 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 446 | AC_VERB_GET_PROC_COEF, 0); |
| 447 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 448 | spec->pll_coef_idx); |
| 449 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 450 | val & ~(1 << spec->pll_coef_bit)); |
| 451 | } |
| 452 | |
| 453 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 454 | unsigned int coef_idx, unsigned int coef_bit) |
| 455 | { |
| 456 | struct alc_spec *spec = codec->spec; |
| 457 | spec->pll_nid = nid; |
| 458 | spec->pll_coef_idx = coef_idx; |
| 459 | spec->pll_coef_bit = coef_bit; |
| 460 | alc_fix_pll(codec); |
| 461 | } |
| 462 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 463 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 464 | * Jack detections for HP auto-mute and mic-switch |
| 465 | */ |
| 466 | |
| 467 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 468 | 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] | 469 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 470 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 471 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 472 | for (i = 0; i < num_pins; i++) { |
| 473 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 474 | if (!nid) |
| 475 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 476 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 477 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 478 | return present; |
| 479 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 480 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 481 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 482 | 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] | 483 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 484 | { |
| 485 | struct alc_spec *spec = codec->spec; |
| 486 | unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 487 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 488 | int i; |
| 489 | |
| 490 | for (i = 0; i < num_pins; i++) { |
| 491 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 492 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 493 | if (!nid) |
| 494 | break; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 495 | switch (spec->automute_mode) { |
| 496 | case ALC_AUTOMUTE_PIN: |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 497 | /* don't reset VREF value in case it's controlling |
| 498 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 499 | */ |
| 500 | if (spec->keep_vref_in_automute) { |
| 501 | val = snd_hda_codec_read(codec, nid, 0, |
| 502 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 503 | val &= ~PIN_HP; |
| 504 | } else |
| 505 | val = 0; |
| 506 | val |= pin_bits; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 507 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 508 | break; |
| 509 | case ALC_AUTOMUTE_AMP: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 510 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 511 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 512 | break; |
| 513 | case ALC_AUTOMUTE_MIXER: |
| 514 | nid = spec->automute_mixer_nid[i]; |
| 515 | if (!nid) |
| 516 | break; |
| 517 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 518 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 519 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, |
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; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 522 | } |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 523 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 524 | } |
| 525 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 526 | /* Toggle outputs muting */ |
| 527 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 528 | { |
| 529 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 530 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 531 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 532 | /* Control HP pins/amps depending on master_mute state; |
| 533 | * in general, HP pins/amps control should be enabled in all cases, |
| 534 | * but currently set only for master_mute, just to be safe |
| 535 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 536 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 537 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 538 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 539 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 540 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 541 | on = 0; |
| 542 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 543 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 544 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 545 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 546 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 547 | |
| 548 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 549 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 550 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 551 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 552 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 553 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 554 | on = 0; |
| 555 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 556 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 557 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 558 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 559 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 560 | } |
| 561 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 562 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 563 | { |
| 564 | struct alc_spec *spec = codec->spec; |
| 565 | if (spec->automute_hook) |
| 566 | spec->automute_hook(codec); |
| 567 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 568 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 569 | } |
| 570 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 571 | /* standard HP-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 572 | static void alc_hp_automute(struct hda_codec *codec) |
| 573 | { |
| 574 | struct alc_spec *spec = codec->spec; |
| 575 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 576 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 577 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 578 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 579 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 580 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 581 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 582 | } |
| 583 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 584 | /* standard line-out-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 585 | static void alc_line_automute(struct hda_codec *codec) |
| 586 | { |
| 587 | struct alc_spec *spec = codec->spec; |
| 588 | |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 589 | /* check LO jack only when it's different from HP */ |
| 590 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 591 | return; |
| 592 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 593 | spec->line_jack_present = |
| 594 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 595 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 596 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 597 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 598 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 599 | } |
| 600 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 601 | #define get_connection_index(codec, mux, nid) \ |
| 602 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 603 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 604 | /* standard mic auto-switch helper */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 605 | static void alc_mic_automute(struct hda_codec *codec) |
| 606 | { |
| 607 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 608 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 609 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 610 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 611 | return; |
| 612 | if (snd_BUG_ON(!spec->adc_nids)) |
| 613 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 614 | 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] | 615 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 616 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 617 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 618 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 619 | else if (spec->dock_mic_idx >= 0 && |
| 620 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 621 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 622 | else |
| 623 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 624 | } |
| 625 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 626 | /* handle the specified unsol action (ALC_XXX_EVENT) */ |
| 627 | static void alc_exec_unsol_event(struct hda_codec *codec, int action) |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 628 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 629 | switch (action) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 630 | case ALC_HP_EVENT: |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 631 | alc_hp_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 632 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 633 | case ALC_FRONT_EVENT: |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 634 | alc_line_automute(codec); |
| 635 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 636 | case ALC_MIC_EVENT: |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 637 | alc_mic_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 638 | break; |
| 639 | } |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 640 | snd_hda_jack_report_sync(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 641 | } |
| 642 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 643 | /* update the master volume per volume-knob's unsol event */ |
| 644 | static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) |
| 645 | { |
| 646 | unsigned int val; |
| 647 | struct snd_kcontrol *kctl; |
| 648 | struct snd_ctl_elem_value *uctl; |
| 649 | |
| 650 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 651 | if (!kctl) |
| 652 | return; |
| 653 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 654 | if (!uctl) |
| 655 | return; |
| 656 | val = snd_hda_codec_read(codec, nid, 0, |
| 657 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 658 | val &= HDA_AMP_VOLMASK; |
| 659 | uctl->value.integer.value[0] = val; |
| 660 | uctl->value.integer.value[1] = val; |
| 661 | kctl->put(kctl, uctl); |
| 662 | kfree(uctl); |
| 663 | } |
| 664 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 665 | /* unsolicited event for HP jack sensing */ |
| 666 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
| 667 | { |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 668 | int action; |
| 669 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 670 | if (codec->vendor_id == 0x10ec0880) |
| 671 | res >>= 28; |
| 672 | else |
| 673 | res >>= 26; |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 674 | action = snd_hda_jack_get_action(codec, res); |
David Henningsson | e21af48 | 2012-03-05 11:38:46 +0100 | [diff] [blame] | 675 | if (action == ALC_DCVOL_EVENT) { |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 676 | /* Execute the dc-vol event here as it requires the NID |
| 677 | * but we don't pass NID to alc_exec_unsol_event(). |
| 678 | * Once when we convert all static quirks to the auto-parser, |
| 679 | * this can be integerated into there. |
| 680 | */ |
| 681 | struct hda_jack_tbl *jack; |
| 682 | jack = snd_hda_jack_tbl_get_from_tag(codec, res); |
| 683 | if (jack) |
| 684 | alc_update_knob_master(codec, jack->nid); |
| 685 | return; |
| 686 | } |
| 687 | alc_exec_unsol_event(codec, action); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 688 | } |
| 689 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 690 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 691 | static void alc_inithook(struct hda_codec *codec) |
| 692 | { |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 693 | alc_hp_automute(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 694 | alc_line_automute(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 695 | alc_mic_automute(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 696 | } |
| 697 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 698 | /* additional initialization for ALC888 variants */ |
| 699 | static void alc888_coef_init(struct hda_codec *codec) |
| 700 | { |
| 701 | unsigned int tmp; |
| 702 | |
| 703 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 704 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 705 | 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] | 706 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 707 | /* alc888S-VC */ |
| 708 | snd_hda_codec_read(codec, 0x20, 0, |
| 709 | AC_VERB_SET_PROC_COEF, 0x830); |
| 710 | else |
| 711 | /* alc888-VB */ |
| 712 | snd_hda_codec_read(codec, 0x20, 0, |
| 713 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 714 | } |
| 715 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 716 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 717 | static void alc889_coef_init(struct hda_codec *codec) |
| 718 | { |
| 719 | unsigned int tmp; |
| 720 | |
| 721 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 722 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 723 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 724 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 725 | } |
| 726 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 727 | /* turn on/off EAPD control (only if available) */ |
| 728 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 729 | { |
| 730 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 731 | return; |
| 732 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 733 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 734 | on ? 2 : 0); |
| 735 | } |
| 736 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 737 | /* turn on/off EAPD controls of the codec */ |
| 738 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 739 | { |
| 740 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 741 | static hda_nid_t pins[] = { |
| 742 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 743 | }; |
| 744 | hda_nid_t *p; |
| 745 | for (p = pins; *p; p++) |
| 746 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 747 | } |
| 748 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 749 | /* generic shutup callback; |
| 750 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 751 | */ |
| 752 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 753 | { |
| 754 | alc_auto_setup_eapd(codec, false); |
| 755 | msleep(200); |
| 756 | } |
| 757 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 758 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 759 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 760 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 761 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 762 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 763 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 764 | switch (type) { |
| 765 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 766 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 767 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 768 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 769 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 770 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 771 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 772 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 773 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 774 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 775 | switch (codec->vendor_id) { |
| 776 | case 0x10ec0260: |
| 777 | snd_hda_codec_write(codec, 0x1a, 0, |
| 778 | AC_VERB_SET_COEF_INDEX, 7); |
| 779 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 780 | AC_VERB_GET_PROC_COEF, 0); |
| 781 | snd_hda_codec_write(codec, 0x1a, 0, |
| 782 | AC_VERB_SET_COEF_INDEX, 7); |
| 783 | snd_hda_codec_write(codec, 0x1a, 0, |
| 784 | AC_VERB_SET_PROC_COEF, |
| 785 | tmp | 0x2010); |
| 786 | break; |
| 787 | case 0x10ec0262: |
| 788 | case 0x10ec0880: |
| 789 | case 0x10ec0882: |
| 790 | case 0x10ec0883: |
| 791 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 792 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 793 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 794 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 795 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 796 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 797 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 798 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 799 | #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] | 800 | case 0x10ec0267: |
| 801 | case 0x10ec0268: |
| 802 | snd_hda_codec_write(codec, 0x20, 0, |
| 803 | AC_VERB_SET_COEF_INDEX, 7); |
| 804 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 805 | AC_VERB_GET_PROC_COEF, 0); |
| 806 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 807 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 808 | snd_hda_codec_write(codec, 0x20, 0, |
| 809 | AC_VERB_SET_PROC_COEF, |
| 810 | tmp | 0x3000); |
| 811 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 812 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 813 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 814 | break; |
| 815 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 816 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 817 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 818 | /* |
| 819 | * Auto-Mute mode mixer enum support |
| 820 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 821 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 822 | struct snd_ctl_elem_info *uinfo) |
| 823 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 824 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 825 | struct alc_spec *spec = codec->spec; |
| 826 | static const char * const texts2[] = { |
| 827 | "Disabled", "Enabled" |
| 828 | }; |
| 829 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 830 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 831 | }; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 832 | const char * const *texts; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 833 | |
| 834 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 835 | uinfo->count = 1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 836 | if (spec->automute_speaker_possible && spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 837 | uinfo->value.enumerated.items = 3; |
| 838 | texts = texts3; |
| 839 | } else { |
| 840 | uinfo->value.enumerated.items = 2; |
| 841 | texts = texts2; |
| 842 | } |
| 843 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 844 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 845 | strcpy(uinfo->value.enumerated.name, |
| 846 | texts[uinfo->value.enumerated.item]); |
| 847 | return 0; |
| 848 | } |
| 849 | |
| 850 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 851 | struct snd_ctl_elem_value *ucontrol) |
| 852 | { |
| 853 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 854 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 855 | unsigned int val = 0; |
| 856 | if (spec->automute_speaker) |
| 857 | val++; |
| 858 | if (spec->automute_lo) |
| 859 | val++; |
| 860 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 861 | ucontrol->value.enumerated.item[0] = val; |
| 862 | return 0; |
| 863 | } |
| 864 | |
| 865 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 866 | struct snd_ctl_elem_value *ucontrol) |
| 867 | { |
| 868 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 869 | struct alc_spec *spec = codec->spec; |
| 870 | |
| 871 | switch (ucontrol->value.enumerated.item[0]) { |
| 872 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 873 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 874 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 875 | spec->automute_speaker = 0; |
| 876 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 877 | break; |
| 878 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 879 | if (spec->automute_speaker_possible) { |
| 880 | if (!spec->automute_lo && spec->automute_speaker) |
| 881 | return 0; |
| 882 | spec->automute_speaker = 1; |
| 883 | spec->automute_lo = 0; |
| 884 | } else if (spec->automute_lo_possible) { |
| 885 | if (spec->automute_lo) |
| 886 | return 0; |
| 887 | spec->automute_lo = 1; |
| 888 | } else |
| 889 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 890 | break; |
| 891 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 892 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 893 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 894 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 895 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 896 | spec->automute_speaker = 1; |
| 897 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 898 | break; |
| 899 | default: |
| 900 | return -EINVAL; |
| 901 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 902 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 903 | return 1; |
| 904 | } |
| 905 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 906 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 908 | .name = "Auto-Mute Mode", |
| 909 | .info = alc_automute_mode_info, |
| 910 | .get = alc_automute_mode_get, |
| 911 | .put = alc_automute_mode_put, |
| 912 | }; |
| 913 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 914 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
| 915 | { |
| 916 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 917 | return snd_array_new(&spec->kctls); |
| 918 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 919 | |
| 920 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 921 | { |
| 922 | struct alc_spec *spec = codec->spec; |
| 923 | struct snd_kcontrol_new *knew; |
| 924 | |
| 925 | knew = alc_kcontrol_new(spec); |
| 926 | if (!knew) |
| 927 | return -ENOMEM; |
| 928 | *knew = alc_automute_mode_enum; |
| 929 | knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); |
| 930 | if (!knew->name) |
| 931 | return -ENOMEM; |
| 932 | return 0; |
| 933 | } |
| 934 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 935 | /* |
| 936 | * Check the availability of HP/line-out auto-mute; |
| 937 | * Set up appropriately if really supported |
| 938 | */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 939 | static void alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 940 | { |
| 941 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 942 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 943 | int present = 0; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 944 | int i; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 945 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 946 | if (cfg->hp_pins[0]) |
| 947 | present++; |
| 948 | if (cfg->line_out_pins[0]) |
| 949 | present++; |
| 950 | if (cfg->speaker_pins[0]) |
| 951 | present++; |
| 952 | if (present < 2) /* need two different output types */ |
| 953 | return; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 954 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 955 | if (!cfg->speaker_pins[0] && |
| 956 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 957 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 958 | sizeof(cfg->speaker_pins)); |
| 959 | cfg->speaker_outs = cfg->line_outs; |
| 960 | } |
| 961 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 962 | if (!cfg->hp_pins[0] && |
| 963 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 964 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 965 | sizeof(cfg->hp_pins)); |
| 966 | cfg->hp_outs = cfg->line_outs; |
| 967 | } |
| 968 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 969 | spec->automute_mode = ALC_AUTOMUTE_PIN; |
| 970 | |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 971 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 972 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 973 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 974 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 975 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 976 | nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 977 | snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 978 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 979 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 980 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 981 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 982 | if (cfg->speaker_outs) |
| 983 | for (i = 0; i < cfg->line_outs; i++) { |
| 984 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 985 | if (!is_jack_detectable(codec, nid)) |
| 986 | continue; |
| 987 | snd_printdd("realtek: Enable Line-Out " |
| 988 | "auto-muting on NID 0x%x\n", nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 989 | snd_hda_jack_detect_enable(codec, nid, |
| 990 | ALC_FRONT_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 991 | spec->detect_lo = 1; |
| 992 | } |
| 993 | spec->automute_lo_possible = spec->detect_hp; |
| 994 | } |
| 995 | |
| 996 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 997 | (spec->detect_hp || spec->detect_lo); |
| 998 | |
| 999 | spec->automute_lo = spec->automute_lo_possible; |
| 1000 | spec->automute_speaker = spec->automute_speaker_possible; |
| 1001 | |
| 1002 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 1003 | /* create a control for automute mode */ |
| 1004 | alc_add_automute_mode_enum(codec); |
| 1005 | spec->unsol_event = alc_sku_unsol_event; |
| 1006 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1007 | } |
| 1008 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1009 | /* 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] | 1010 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1011 | { |
| 1012 | int i; |
| 1013 | for (i = 0; i < nums; i++) |
| 1014 | if (list[i] == nid) |
| 1015 | return i; |
| 1016 | return -1; |
| 1017 | } |
| 1018 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1019 | /* check whether dynamic ADC-switching is available */ |
| 1020 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 1021 | { |
| 1022 | struct alc_spec *spec = codec->spec; |
| 1023 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 1024 | int i, n, idx; |
| 1025 | hda_nid_t cap, pin; |
| 1026 | |
| 1027 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1028 | return false; |
| 1029 | |
| 1030 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1031 | cap = spec->private_capsrc_nids[n]; |
| 1032 | for (i = 0; i < imux->num_items; i++) { |
| 1033 | pin = spec->imux_pins[i]; |
| 1034 | if (!pin) |
| 1035 | return false; |
| 1036 | if (get_connection_index(codec, cap, pin) < 0) |
| 1037 | break; |
| 1038 | } |
| 1039 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1040 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | for (i = 0; i < imux->num_items; i++) { |
| 1044 | pin = spec->imux_pins[i]; |
| 1045 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1046 | cap = spec->private_capsrc_nids[n]; |
| 1047 | idx = get_connection_index(codec, cap, pin); |
| 1048 | if (idx >= 0) { |
| 1049 | imux->items[i].index = idx; |
| 1050 | spec->dyn_adc_idx[i] = n; |
| 1051 | break; |
| 1052 | } |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1057 | spec->dyn_adc_switch = 1; |
| 1058 | return true; |
| 1059 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1060 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1061 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1062 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1063 | { |
| 1064 | struct alc_spec *spec = codec->spec; |
| 1065 | const struct hda_input_mux *imux; |
| 1066 | |
| 1067 | if (!spec->auto_mic) |
| 1068 | return false; |
| 1069 | if (spec->auto_mic_valid_imux) |
| 1070 | return true; /* already checked */ |
| 1071 | |
| 1072 | /* fill up imux indices */ |
| 1073 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1074 | spec->auto_mic = 0; |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | imux = spec->input_mux; |
| 1079 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1080 | spec->imux_pins, imux->num_items); |
| 1081 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1082 | spec->imux_pins, imux->num_items); |
| 1083 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1084 | spec->imux_pins, imux->num_items); |
| 1085 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1086 | spec->auto_mic = 0; |
| 1087 | return false; /* no corresponding imux */ |
| 1088 | } |
| 1089 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1090 | 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] | 1091 | if (spec->dock_mic_pin) |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1092 | snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, |
| 1093 | ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1094 | |
| 1095 | spec->auto_mic_valid_imux = 1; |
| 1096 | spec->auto_mic = 1; |
| 1097 | return true; |
| 1098 | } |
| 1099 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1100 | /* |
| 1101 | * Check the availability of auto-mic switch; |
| 1102 | * Set up if really supported |
| 1103 | */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1104 | static void alc_init_auto_mic(struct hda_codec *codec) |
| 1105 | { |
| 1106 | struct alc_spec *spec = codec->spec; |
| 1107 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1108 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1109 | int i; |
| 1110 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1111 | if (spec->shared_mic_hp) |
| 1112 | return; /* no auto-mic for the shared I/O */ |
| 1113 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1114 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1115 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1116 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1117 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1118 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1119 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1120 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1121 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1122 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1123 | if (fixed) |
| 1124 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1125 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1126 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1127 | fixed = nid; |
| 1128 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1129 | case INPUT_PIN_ATTR_UNUSED: |
| 1130 | return; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1131 | case INPUT_PIN_ATTR_DOCK: |
| 1132 | if (dock) |
| 1133 | return; /* already occupied */ |
| 1134 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 1135 | return; /* invalid type */ |
| 1136 | dock = nid; |
| 1137 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1138 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1139 | if (ext) |
| 1140 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1141 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1142 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1143 | ext = nid; |
| 1144 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1145 | } |
| 1146 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1147 | if (!ext && dock) { |
| 1148 | ext = dock; |
| 1149 | dock = 0; |
| 1150 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1151 | if (!ext || !fixed) |
| 1152 | return; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1153 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1154 | return; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1155 | if (dock && !is_jack_detectable(codec, dock)) |
| 1156 | return; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1157 | |
| 1158 | /* check imux indices */ |
| 1159 | spec->ext_mic_pin = ext; |
| 1160 | spec->int_mic_pin = fixed; |
| 1161 | spec->dock_mic_pin = dock; |
| 1162 | |
| 1163 | spec->auto_mic = 1; |
| 1164 | if (!alc_auto_mic_check_imux(codec)) |
| 1165 | return; |
| 1166 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1167 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1168 | ext, fixed, dock); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1169 | spec->unsol_event = alc_sku_unsol_event; |
| 1170 | } |
| 1171 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1172 | /* check the availabilities of auto-mute and auto-mic switches */ |
| 1173 | static void alc_auto_check_switches(struct hda_codec *codec) |
| 1174 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1175 | alc_init_automute(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1176 | alc_init_auto_mic(codec); |
| 1177 | } |
| 1178 | |
| 1179 | /* |
| 1180 | * Realtek SSID verification |
| 1181 | */ |
| 1182 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1183 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1184 | * the driver to ignore any present sku defines. |
| 1185 | */ |
| 1186 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1187 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1188 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1189 | { |
| 1190 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1191 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1192 | struct alc_spec *spec = codec->spec; |
| 1193 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1194 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1195 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1196 | if (spec->cdefine.fixup) { |
| 1197 | ass = spec->cdefine.sku_cfg; |
| 1198 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1199 | return -1; |
| 1200 | goto do_sku; |
| 1201 | } |
| 1202 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1203 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1204 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1205 | goto do_sku; |
| 1206 | |
| 1207 | nid = 0x1d; |
| 1208 | if (codec->vendor_id == 0x10ec0260) |
| 1209 | nid = 0x17; |
| 1210 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1211 | |
| 1212 | if (!(ass & 1)) { |
| 1213 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1214 | codec->chip_name, ass); |
| 1215 | return -1; |
| 1216 | } |
| 1217 | |
| 1218 | /* check sum */ |
| 1219 | tmp = 0; |
| 1220 | for (i = 1; i < 16; i++) { |
| 1221 | if ((ass >> i) & 1) |
| 1222 | tmp++; |
| 1223 | } |
| 1224 | if (((ass >> 16) & 0xf) != tmp) |
| 1225 | return -1; |
| 1226 | |
| 1227 | spec->cdefine.port_connectivity = ass >> 30; |
| 1228 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1229 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1230 | spec->cdefine.customization = ass >> 8; |
| 1231 | do_sku: |
| 1232 | spec->cdefine.sku_cfg = ass; |
| 1233 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1234 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1235 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1236 | spec->cdefine.override = ass & 0x1; |
| 1237 | |
| 1238 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1239 | nid, spec->cdefine.sku_cfg); |
| 1240 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1241 | spec->cdefine.port_connectivity); |
| 1242 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1243 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1244 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1245 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1246 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1247 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1248 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1249 | |
| 1250 | return 0; |
| 1251 | } |
| 1252 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1253 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1254 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1255 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1256 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1257 | } |
| 1258 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1259 | /* check subsystem ID and set up device-specific initialization; |
| 1260 | * return 1 if initialized, 0 if invalid SSID |
| 1261 | */ |
| 1262 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1263 | * 31 ~ 16 : Manufacture ID |
| 1264 | * 15 ~ 8 : SKU ID |
| 1265 | * 7 ~ 0 : Assembly ID |
| 1266 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1267 | */ |
| 1268 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1269 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1270 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1271 | { |
| 1272 | unsigned int ass, tmp, i; |
| 1273 | unsigned nid; |
| 1274 | struct alc_spec *spec = codec->spec; |
| 1275 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1276 | if (spec->cdefine.fixup) { |
| 1277 | ass = spec->cdefine.sku_cfg; |
| 1278 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1279 | return 0; |
| 1280 | goto do_sku; |
| 1281 | } |
| 1282 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1283 | ass = codec->subsystem_id & 0xffff; |
| 1284 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1285 | goto do_sku; |
| 1286 | |
| 1287 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1288 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1289 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1290 | * 29~21 : reserve |
| 1291 | * 20 : PCBEEP input |
| 1292 | * 19~16 : Check sum (15:1) |
| 1293 | * 15~1 : Custom |
| 1294 | * 0 : override |
| 1295 | */ |
| 1296 | nid = 0x1d; |
| 1297 | if (codec->vendor_id == 0x10ec0260) |
| 1298 | nid = 0x17; |
| 1299 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1300 | snd_printd("realtek: No valid SSID, " |
| 1301 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1302 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1303 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1304 | return 0; |
| 1305 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1306 | return 0; |
| 1307 | |
| 1308 | /* check sum */ |
| 1309 | tmp = 0; |
| 1310 | for (i = 1; i < 16; i++) { |
| 1311 | if ((ass >> i) & 1) |
| 1312 | tmp++; |
| 1313 | } |
| 1314 | if (((ass >> 16) & 0xf) != tmp) |
| 1315 | return 0; |
| 1316 | do_sku: |
| 1317 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1318 | ass & 0xffff, codec->vendor_id); |
| 1319 | /* |
| 1320 | * 0 : override |
| 1321 | * 1 : Swap Jack |
| 1322 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1323 | * 3~5 : External Amplifier control |
| 1324 | * 7~6 : Reserved |
| 1325 | */ |
| 1326 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1327 | switch (tmp) { |
| 1328 | case 1: |
| 1329 | spec->init_amp = ALC_INIT_GPIO1; |
| 1330 | break; |
| 1331 | case 3: |
| 1332 | spec->init_amp = ALC_INIT_GPIO2; |
| 1333 | break; |
| 1334 | case 7: |
| 1335 | spec->init_amp = ALC_INIT_GPIO3; |
| 1336 | break; |
| 1337 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1338 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1339 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1340 | break; |
| 1341 | } |
| 1342 | |
| 1343 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1344 | * when the external headphone out jack is plugged" |
| 1345 | */ |
| 1346 | if (!(ass & 0x8000)) |
| 1347 | return 1; |
| 1348 | /* |
| 1349 | * 10~8 : Jack location |
| 1350 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1351 | * 14~13: Resvered |
| 1352 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1353 | * when the external headphone out jack is plugged" |
| 1354 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1355 | if (!spec->autocfg.hp_pins[0] && |
| 1356 | !(spec->autocfg.line_out_pins[0] && |
| 1357 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1358 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1359 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1360 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1361 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1362 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1363 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1364 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1365 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1366 | else if (tmp == 3) |
| 1367 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1368 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1369 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1370 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1371 | spec->autocfg.line_outs)) |
| 1372 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1373 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1374 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1375 | return 1; |
| 1376 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1377 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1378 | /* Check the validity of ALC subsystem-id |
| 1379 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1380 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1381 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1382 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1383 | struct alc_spec *spec = codec->spec; |
| 1384 | snd_printd("realtek: " |
| 1385 | "Enable default setup for auto mode as fallback\n"); |
| 1386 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1387 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1388 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1389 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1390 | /* |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1391 | * Fix-up pin default configurations and add default verbs |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1392 | */ |
| 1393 | |
| 1394 | struct alc_pincfg { |
| 1395 | hda_nid_t nid; |
| 1396 | u32 val; |
| 1397 | }; |
| 1398 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1399 | struct alc_model_fixup { |
| 1400 | const int id; |
| 1401 | const char *name; |
| 1402 | }; |
| 1403 | |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1404 | struct alc_fixup { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1405 | int type; |
Takashi Iwai | 361fe6e | 2011-01-14 09:55:32 +0100 | [diff] [blame] | 1406 | bool chained; |
| 1407 | int chain_id; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1408 | union { |
| 1409 | unsigned int sku; |
| 1410 | const struct alc_pincfg *pins; |
| 1411 | const struct hda_verb *verbs; |
| 1412 | void (*func)(struct hda_codec *codec, |
| 1413 | const struct alc_fixup *fix, |
| 1414 | int action); |
| 1415 | } v; |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1416 | }; |
| 1417 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1418 | enum { |
| 1419 | ALC_FIXUP_INVALID, |
| 1420 | ALC_FIXUP_SKU, |
| 1421 | ALC_FIXUP_PINS, |
| 1422 | ALC_FIXUP_VERBS, |
| 1423 | ALC_FIXUP_FUNC, |
| 1424 | }; |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1425 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1426 | enum { |
| 1427 | ALC_FIXUP_ACT_PRE_PROBE, |
| 1428 | ALC_FIXUP_ACT_PROBE, |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1429 | ALC_FIXUP_ACT_INIT, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1430 | ALC_FIXUP_ACT_BUILD, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1431 | }; |
| 1432 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 1433 | static void alc_apply_pincfgs(struct hda_codec *codec, |
| 1434 | const struct alc_pincfg *cfg) |
| 1435 | { |
| 1436 | for (; cfg->nid; cfg++) |
| 1437 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); |
| 1438 | } |
| 1439 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1440 | static void alc_apply_fixup(struct hda_codec *codec, int action) |
| 1441 | { |
| 1442 | struct alc_spec *spec = codec->spec; |
| 1443 | int id = spec->fixup_id; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1444 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1445 | const char *modelname = spec->fixup_name; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1446 | #endif |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1447 | int depth = 0; |
| 1448 | |
| 1449 | if (!spec->fixup_list) |
| 1450 | return; |
| 1451 | |
| 1452 | while (id >= 0) { |
| 1453 | const struct alc_fixup *fix = spec->fixup_list + id; |
| 1454 | const struct alc_pincfg *cfg; |
| 1455 | |
| 1456 | switch (fix->type) { |
| 1457 | case ALC_FIXUP_SKU: |
| 1458 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) |
Jesper Juhl | e53de8f | 2011-11-13 23:11:50 +0100 | [diff] [blame] | 1459 | break; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1460 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1461 | "Apply sku override for %s\n", |
| 1462 | codec->chip_name, modelname); |
| 1463 | spec->cdefine.sku_cfg = fix->v.sku; |
| 1464 | spec->cdefine.fixup = 1; |
| 1465 | break; |
| 1466 | case ALC_FIXUP_PINS: |
| 1467 | cfg = fix->v.pins; |
| 1468 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) |
| 1469 | break; |
| 1470 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1471 | "Apply pincfg for %s\n", |
| 1472 | codec->chip_name, modelname); |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 1473 | alc_apply_pincfgs(codec, cfg); |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1474 | break; |
| 1475 | case ALC_FIXUP_VERBS: |
| 1476 | if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) |
| 1477 | break; |
| 1478 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1479 | "Apply fix-verbs for %s\n", |
| 1480 | codec->chip_name, modelname); |
| 1481 | add_verb(codec->spec, fix->v.verbs); |
| 1482 | break; |
| 1483 | case ALC_FIXUP_FUNC: |
| 1484 | if (!fix->v.func) |
| 1485 | break; |
| 1486 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1487 | "Apply fix-func for %s\n", |
| 1488 | codec->chip_name, modelname); |
| 1489 | fix->v.func(codec, fix, action); |
| 1490 | break; |
| 1491 | default: |
| 1492 | snd_printk(KERN_ERR "hda_codec: %s: " |
| 1493 | "Invalid fixup type %d\n", |
| 1494 | codec->chip_name, fix->type); |
| 1495 | break; |
| 1496 | } |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1497 | if (!fix->chained) |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1498 | break; |
| 1499 | if (++depth > 10) |
| 1500 | break; |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1501 | id = fix->chain_id; |
Takashi Iwai | 9d57883 | 2010-11-22 13:29:19 +0100 | [diff] [blame] | 1502 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1503 | } |
| 1504 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1505 | static void alc_pick_fixup(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1506 | const struct alc_model_fixup *models, |
| 1507 | const struct snd_pci_quirk *quirk, |
| 1508 | const struct alc_fixup *fixlist) |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1509 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1510 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1511 | const struct snd_pci_quirk *q; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1512 | int id = -1; |
| 1513 | const char *name = NULL; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1514 | |
Takashi Iwai | 9155f82 | 2012-02-20 18:41:02 +0100 | [diff] [blame] | 1515 | /* when model=nofixup is given, don't pick up any fixups */ |
| 1516 | if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { |
| 1517 | spec->fixup_list = NULL; |
| 1518 | spec->fixup_id = -1; |
| 1519 | return; |
| 1520 | } |
| 1521 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1522 | if (codec->modelname && models) { |
| 1523 | while (models->name) { |
| 1524 | if (!strcmp(codec->modelname, models->name)) { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1525 | id = models->id; |
| 1526 | name = models->name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1527 | break; |
| 1528 | } |
| 1529 | models++; |
| 1530 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1531 | } |
| 1532 | if (id < 0) { |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1533 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| 1534 | if (q) { |
| 1535 | id = q->value; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1536 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1537 | name = q->name; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1538 | #endif |
| 1539 | } |
| 1540 | } |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1541 | if (id < 0) { |
| 1542 | for (q = quirk; q->subvendor; q++) { |
| 1543 | unsigned int vendorid = |
| 1544 | q->subdevice | (q->subvendor << 16); |
| 1545 | if (vendorid == codec->subsystem_id) { |
| 1546 | id = q->value; |
| 1547 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 1548 | name = q->name; |
| 1549 | #endif |
| 1550 | break; |
| 1551 | } |
| 1552 | } |
| 1553 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1554 | |
| 1555 | spec->fixup_id = id; |
| 1556 | if (id >= 0) { |
| 1557 | spec->fixup_list = fixlist; |
| 1558 | spec->fixup_name = name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1559 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1560 | } |
| 1561 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1562 | /* |
| 1563 | * COEF access helper functions |
| 1564 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1565 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1566 | unsigned int coef_idx) |
| 1567 | { |
| 1568 | unsigned int val; |
| 1569 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1570 | coef_idx); |
| 1571 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1572 | AC_VERB_GET_PROC_COEF, 0); |
| 1573 | return val; |
| 1574 | } |
| 1575 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1576 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1577 | unsigned int coef_val) |
| 1578 | { |
| 1579 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1580 | coef_idx); |
| 1581 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1582 | coef_val); |
| 1583 | } |
| 1584 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1585 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1586 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1587 | { |
| 1588 | struct alc_spec *spec = codec->spec; |
| 1589 | if (!spec->coef0) |
| 1590 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1591 | return spec->coef0; |
| 1592 | } |
| 1593 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1594 | /* |
| 1595 | * Digital I/O handling |
| 1596 | */ |
| 1597 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1598 | /* set right pin controls for digital I/O */ |
| 1599 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1600 | { |
| 1601 | struct alc_spec *spec = codec->spec; |
| 1602 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1603 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1604 | |
| 1605 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1606 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1607 | if (!pin) |
| 1608 | continue; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1609 | snd_hda_set_pin_ctl(codec, pin, PIN_OUT); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 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) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1622 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1623 | } |
| 1624 | |
| 1625 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1626 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1627 | { |
| 1628 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1629 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1630 | hda_nid_t dig_nid; |
| 1631 | |
| 1632 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1633 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1634 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1635 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1636 | err = snd_hda_get_connections(codec, |
| 1637 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1638 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1639 | if (err <= 0) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1640 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1641 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1642 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1643 | spec->multiout.dig_out_nid = dig_nid; |
| 1644 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1645 | } else { |
| 1646 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1647 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1648 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1649 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1650 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1651 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1652 | } |
| 1653 | |
| 1654 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1655 | dig_nid = codec->start_nid; |
| 1656 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1657 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1658 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1659 | continue; |
| 1660 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1661 | continue; |
| 1662 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1663 | continue; |
| 1664 | err = get_connection_index(codec, dig_nid, |
| 1665 | spec->autocfg.dig_in_pin); |
| 1666 | if (err >= 0) { |
| 1667 | spec->dig_in_nid = dig_nid; |
| 1668 | break; |
| 1669 | } |
| 1670 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1671 | } |
| 1672 | } |
| 1673 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1674 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1675 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1676 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1677 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1678 | struct snd_ctl_elem_info *uinfo) |
| 1679 | { |
| 1680 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1681 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1682 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1683 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1684 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1685 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1686 | if (spec->vol_in_capsrc) |
| 1687 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1688 | else |
| 1689 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1690 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1691 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1692 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1693 | return err; |
| 1694 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1695 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1696 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1697 | unsigned int size, unsigned int __user *tlv) |
| 1698 | { |
| 1699 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1700 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1701 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1702 | int err; |
| 1703 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1704 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1705 | if (spec->vol_in_capsrc) |
| 1706 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1707 | else |
| 1708 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1709 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1710 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1711 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1712 | return err; |
| 1713 | } |
| 1714 | |
| 1715 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1716 | struct snd_ctl_elem_value *ucontrol); |
| 1717 | |
| 1718 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1719 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1720 | getput_call_t func, bool check_adc_switch) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1721 | { |
| 1722 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1723 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1724 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1725 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1726 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1727 | if (check_adc_switch && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1728 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1729 | kcontrol->private_value = |
| 1730 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1731 | 3, 0, HDA_INPUT); |
| 1732 | err = func(kcontrol, ucontrol); |
| 1733 | if (err < 0) |
| 1734 | goto error; |
| 1735 | } |
| 1736 | } else { |
| 1737 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1738 | if (spec->vol_in_capsrc) |
| 1739 | kcontrol->private_value = |
| 1740 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1741 | 3, 0, HDA_OUTPUT); |
| 1742 | else |
| 1743 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1744 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1745 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1746 | err = func(kcontrol, ucontrol); |
| 1747 | } |
| 1748 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1749 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1750 | return err; |
| 1751 | } |
| 1752 | |
| 1753 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1754 | struct snd_ctl_elem_value *ucontrol) |
| 1755 | { |
| 1756 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1757 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1758 | } |
| 1759 | |
| 1760 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1761 | struct snd_ctl_elem_value *ucontrol) |
| 1762 | { |
| 1763 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1764 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1765 | } |
| 1766 | |
| 1767 | /* capture mixer elements */ |
| 1768 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1769 | |
| 1770 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1771 | struct snd_ctl_elem_value *ucontrol) |
| 1772 | { |
| 1773 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1774 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1775 | } |
| 1776 | |
| 1777 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1778 | struct snd_ctl_elem_value *ucontrol) |
| 1779 | { |
| 1780 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1781 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1782 | } |
| 1783 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1784 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1785 | { \ |
| 1786 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1787 | .name = "Capture Switch", \ |
| 1788 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1789 | .count = num, \ |
| 1790 | .info = alc_cap_sw_info, \ |
| 1791 | .get = alc_cap_sw_get, \ |
| 1792 | .put = alc_cap_sw_put, \ |
| 1793 | }, \ |
| 1794 | { \ |
| 1795 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1796 | .name = "Capture Volume", \ |
| 1797 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1798 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1799 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1800 | .count = num, \ |
| 1801 | .info = alc_cap_vol_info, \ |
| 1802 | .get = alc_cap_vol_get, \ |
| 1803 | .put = alc_cap_vol_put, \ |
| 1804 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1805 | } |
| 1806 | |
| 1807 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1808 | { \ |
| 1809 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1810 | /* .name = "Capture Source", */ \ |
| 1811 | .name = "Input Source", \ |
| 1812 | .count = num, \ |
| 1813 | .info = alc_mux_enum_info, \ |
| 1814 | .get = alc_mux_enum_get, \ |
| 1815 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1816 | } |
| 1817 | |
| 1818 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1819 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1820 | _DEFINE_CAPMIX(num), \ |
| 1821 | _DEFINE_CAPSRC(num), \ |
| 1822 | { } /* end */ \ |
| 1823 | } |
| 1824 | |
| 1825 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1826 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1827 | _DEFINE_CAPMIX(num), \ |
| 1828 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1829 | } |
| 1830 | |
| 1831 | /* up to three ADCs */ |
| 1832 | DEFINE_CAPMIX(1); |
| 1833 | DEFINE_CAPMIX(2); |
| 1834 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1835 | DEFINE_CAPMIX_NOSRC(1); |
| 1836 | DEFINE_CAPMIX_NOSRC(2); |
| 1837 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1838 | |
| 1839 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1840 | * virtual master controls |
| 1841 | */ |
| 1842 | |
| 1843 | /* |
| 1844 | * slave controls for virtual master |
| 1845 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1846 | static const char * const alc_slave_pfxs[] = { |
| 1847 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1848 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1849 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1850 | NULL, |
| 1851 | }; |
| 1852 | |
| 1853 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1854 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1855 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1856 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1857 | #define NID_MAPPING (-1) |
| 1858 | |
| 1859 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1860 | #define SUBDEV_HP_ (1 << 6) |
| 1861 | #define SUBDEV_LINE_ (2 << 6) |
| 1862 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1863 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1864 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1865 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1866 | static void alc_free_kctls(struct hda_codec *codec); |
| 1867 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1868 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1869 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1870 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1871 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1872 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1873 | { } /* end */ |
| 1874 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1875 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1876 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1877 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | { |
| 1879 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1880 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1881 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1882 | int i, j, err; |
| 1883 | unsigned int u; |
| 1884 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | |
| 1886 | for (i = 0; i < spec->num_mixers; i++) { |
| 1887 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1888 | if (err < 0) |
| 1889 | return err; |
| 1890 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1891 | if (spec->cap_mixer) { |
| 1892 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1893 | if (err < 0) |
| 1894 | return err; |
| 1895 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1897 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1898 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1899 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1900 | if (err < 0) |
| 1901 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1902 | if (!spec->no_analog) { |
| 1903 | err = snd_hda_create_spdif_share_sw(codec, |
| 1904 | &spec->multiout); |
| 1905 | if (err < 0) |
| 1906 | return err; |
| 1907 | spec->multiout.share_spdif = 1; |
| 1908 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | } |
| 1910 | if (spec->dig_in_nid) { |
| 1911 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1912 | if (err < 0) |
| 1913 | return err; |
| 1914 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1915 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1916 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1917 | /* create beep controls if needed */ |
| 1918 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1919 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1920 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1921 | struct snd_kcontrol *kctl; |
| 1922 | kctl = snd_ctl_new1(knew, codec); |
| 1923 | if (!kctl) |
| 1924 | return -ENOMEM; |
| 1925 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1926 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1927 | if (err < 0) |
| 1928 | return err; |
| 1929 | } |
| 1930 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1931 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1932 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1933 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1934 | if (!spec->no_analog && |
| 1935 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1936 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1937 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1938 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1939 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1940 | vmaster_tlv, alc_slave_pfxs, |
| 1941 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1942 | if (err < 0) |
| 1943 | return err; |
| 1944 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1945 | if (!spec->no_analog && |
| 1946 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1947 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1948 | NULL, alc_slave_pfxs, |
| 1949 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1950 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1951 | if (err < 0) |
| 1952 | return err; |
| 1953 | } |
| 1954 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1955 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1956 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1957 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1958 | if (!kctl) |
| 1959 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1960 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1961 | err = snd_hda_add_nid(codec, kctl, i, |
| 1962 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1963 | if (err < 0) |
| 1964 | return err; |
| 1965 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1966 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1967 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1968 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1969 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1970 | if (kname && strcmp(knew->name, kname) == 0) |
| 1971 | continue; |
| 1972 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1973 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1974 | err = snd_hda_add_nid(codec, kctl, i, |
| 1975 | spec->adc_nids[i]); |
| 1976 | if (err < 0) |
| 1977 | return err; |
| 1978 | } |
| 1979 | } |
| 1980 | } |
| 1981 | |
| 1982 | /* other nid->control mapping */ |
| 1983 | for (i = 0; i < spec->num_mixers; i++) { |
| 1984 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1985 | if (knew->iface != NID_MAPPING) |
| 1986 | continue; |
| 1987 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1988 | if (kctl == NULL) |
| 1989 | continue; |
| 1990 | u = knew->subdevice; |
| 1991 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1992 | nid = u & 0x3f; |
| 1993 | if (nid == 0) |
| 1994 | continue; |
| 1995 | switch (u & 0xc0) { |
| 1996 | case SUBDEV_SPEAKER_: |
| 1997 | nid = spec->autocfg.speaker_pins[nid]; |
| 1998 | break; |
| 1999 | case SUBDEV_LINE_: |
| 2000 | nid = spec->autocfg.line_out_pins[nid]; |
| 2001 | break; |
| 2002 | case SUBDEV_HP_: |
| 2003 | nid = spec->autocfg.hp_pins[nid]; |
| 2004 | break; |
| 2005 | default: |
| 2006 | continue; |
| 2007 | } |
| 2008 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2009 | if (err < 0) |
| 2010 | return err; |
| 2011 | } |
| 2012 | u = knew->private_value; |
| 2013 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2014 | nid = u & 0xff; |
| 2015 | if (nid == 0) |
| 2016 | continue; |
| 2017 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2018 | if (err < 0) |
| 2019 | return err; |
| 2020 | } |
| 2021 | } |
| 2022 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 2023 | |
| 2024 | alc_free_kctls(codec); /* no longer needed */ |
| 2025 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 2026 | return 0; |
| 2027 | } |
| 2028 | |
| 2029 | static int alc_build_controls(struct hda_codec *codec) |
| 2030 | { |
| 2031 | struct alc_spec *spec = codec->spec; |
| 2032 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2033 | if (err < 0) |
| 2034 | return err; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 2035 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 2036 | if (err < 0) |
| 2037 | return err; |
| 2038 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 2039 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | } |
| 2041 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2042 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2043 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2044 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2045 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2046 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2047 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2048 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2049 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | static int alc_init(struct hda_codec *codec) |
| 2051 | { |
| 2052 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2053 | unsigned int i; |
| 2054 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 2055 | if (spec->init_hook) |
| 2056 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 2057 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2058 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2059 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2060 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2061 | for (i = 0; i < spec->num_init_verbs; i++) |
| 2062 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2063 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2064 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2065 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2066 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2067 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2068 | snd_hda_jack_report_sync(codec); |
| 2069 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2070 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | return 0; |
| 2072 | } |
| 2073 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2074 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2075 | { |
| 2076 | struct alc_spec *spec = codec->spec; |
| 2077 | |
| 2078 | if (spec->unsol_event) |
| 2079 | spec->unsol_event(codec, res); |
| 2080 | } |
| 2081 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2082 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2083 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2084 | { |
| 2085 | struct alc_spec *spec = codec->spec; |
| 2086 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2087 | } |
| 2088 | #endif |
| 2089 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | /* |
| 2091 | * Analog playback callbacks |
| 2092 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2093 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2095 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | { |
| 2097 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2098 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2099 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | } |
| 2101 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2102 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | struct hda_codec *codec, |
| 2104 | unsigned int stream_tag, |
| 2105 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2106 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | { |
| 2108 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2109 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2110 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | } |
| 2112 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2113 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2115 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | { |
| 2117 | struct alc_spec *spec = codec->spec; |
| 2118 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2119 | } |
| 2120 | |
| 2121 | /* |
| 2122 | * Digital out |
| 2123 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2124 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2126 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | { |
| 2128 | struct alc_spec *spec = codec->spec; |
| 2129 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2130 | } |
| 2131 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2132 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2133 | struct hda_codec *codec, |
| 2134 | unsigned int stream_tag, |
| 2135 | unsigned int format, |
| 2136 | struct snd_pcm_substream *substream) |
| 2137 | { |
| 2138 | struct alc_spec *spec = codec->spec; |
| 2139 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2140 | stream_tag, format, substream); |
| 2141 | } |
| 2142 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2143 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2144 | struct hda_codec *codec, |
| 2145 | struct snd_pcm_substream *substream) |
| 2146 | { |
| 2147 | struct alc_spec *spec = codec->spec; |
| 2148 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2149 | } |
| 2150 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2151 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2153 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | { |
| 2155 | struct alc_spec *spec = codec->spec; |
| 2156 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2157 | } |
| 2158 | |
| 2159 | /* |
| 2160 | * Analog capture |
| 2161 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2162 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | struct hda_codec *codec, |
| 2164 | unsigned int stream_tag, |
| 2165 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2166 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | { |
| 2168 | struct alc_spec *spec = codec->spec; |
| 2169 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2170 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | stream_tag, 0, format); |
| 2172 | return 0; |
| 2173 | } |
| 2174 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2175 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2177 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | { |
| 2179 | struct alc_spec *spec = codec->spec; |
| 2180 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2181 | snd_hda_codec_cleanup_stream(codec, |
| 2182 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2183 | return 0; |
| 2184 | } |
| 2185 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2186 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2187 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2188 | struct hda_codec *codec, |
| 2189 | unsigned int stream_tag, |
| 2190 | unsigned int format, |
| 2191 | struct snd_pcm_substream *substream) |
| 2192 | { |
| 2193 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2194 | 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] | 2195 | spec->cur_adc_stream_tag = stream_tag; |
| 2196 | spec->cur_adc_format = format; |
| 2197 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2198 | return 0; |
| 2199 | } |
| 2200 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2201 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2202 | struct hda_codec *codec, |
| 2203 | struct snd_pcm_substream *substream) |
| 2204 | { |
| 2205 | struct alc_spec *spec = codec->spec; |
| 2206 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2207 | spec->cur_adc = 0; |
| 2208 | return 0; |
| 2209 | } |
| 2210 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2211 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2212 | .substreams = 1, |
| 2213 | .channels_min = 2, |
| 2214 | .channels_max = 2, |
| 2215 | .nid = 0, /* fill later */ |
| 2216 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2217 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2218 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2219 | }, |
| 2220 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2221 | |
| 2222 | /* |
| 2223 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2224 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | .substreams = 1, |
| 2226 | .channels_min = 2, |
| 2227 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2228 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2229 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2230 | .open = alc_playback_pcm_open, |
| 2231 | .prepare = alc_playback_pcm_prepare, |
| 2232 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2233 | }, |
| 2234 | }; |
| 2235 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2236 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2237 | .substreams = 1, |
| 2238 | .channels_min = 2, |
| 2239 | .channels_max = 2, |
| 2240 | /* NID is set in alc_build_pcms */ |
| 2241 | }; |
| 2242 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2243 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2244 | .substreams = 1, |
| 2245 | .channels_min = 2, |
| 2246 | .channels_max = 2, |
| 2247 | /* NID is set in alc_build_pcms */ |
| 2248 | }; |
| 2249 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2250 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2251 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | .channels_min = 2, |
| 2253 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2254 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2256 | .prepare = alc_alt_capture_pcm_prepare, |
| 2257 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2258 | }, |
| 2259 | }; |
| 2260 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2261 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | .substreams = 1, |
| 2263 | .channels_min = 2, |
| 2264 | .channels_max = 2, |
| 2265 | /* NID is set in alc_build_pcms */ |
| 2266 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2267 | .open = alc_dig_playback_pcm_open, |
| 2268 | .close = alc_dig_playback_pcm_close, |
| 2269 | .prepare = alc_dig_playback_pcm_prepare, |
| 2270 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | }, |
| 2272 | }; |
| 2273 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2274 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | .substreams = 1, |
| 2276 | .channels_min = 2, |
| 2277 | .channels_max = 2, |
| 2278 | /* NID is set in alc_build_pcms */ |
| 2279 | }; |
| 2280 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2281 | /* 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] | 2282 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2283 | .substreams = 0, |
| 2284 | .channels_min = 0, |
| 2285 | .channels_max = 0, |
| 2286 | }; |
| 2287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | static int alc_build_pcms(struct hda_codec *codec) |
| 2289 | { |
| 2290 | struct alc_spec *spec = codec->spec; |
| 2291 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2292 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2293 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | int i; |
| 2295 | |
| 2296 | codec->num_pcms = 1; |
| 2297 | codec->pcm_info = info; |
| 2298 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2299 | if (spec->no_analog) |
| 2300 | goto skip_analog; |
| 2301 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2302 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2303 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2304 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2305 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2306 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2307 | p = spec->stream_analog_playback; |
| 2308 | if (!p) |
| 2309 | p = &alc_pcm_analog_playback; |
| 2310 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2311 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 2312 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2313 | if (spec->adc_nids) { |
| 2314 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2315 | if (!p) { |
| 2316 | if (spec->dyn_adc_switch) |
| 2317 | p = &dyn_adc_pcm_analog_capture; |
| 2318 | else |
| 2319 | p = &alc_pcm_analog_capture; |
| 2320 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2321 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2322 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2323 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2325 | if (spec->channel_mode) { |
| 2326 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2327 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2328 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2329 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2330 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | } |
| 2332 | } |
| 2333 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2334 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2335 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2336 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2337 | snprintf(spec->stream_name_digital, |
| 2338 | sizeof(spec->stream_name_digital), |
| 2339 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2340 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2341 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2342 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2344 | if (spec->dig_out_type) |
| 2345 | info->pcm_type = spec->dig_out_type; |
| 2346 | else |
| 2347 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2348 | if (spec->multiout.dig_out_nid) { |
| 2349 | p = spec->stream_digital_playback; |
| 2350 | if (!p) |
| 2351 | p = &alc_pcm_digital_playback; |
| 2352 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2354 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2355 | if (spec->dig_in_nid) { |
| 2356 | p = spec->stream_digital_capture; |
| 2357 | if (!p) |
| 2358 | p = &alc_pcm_digital_capture; |
| 2359 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2360 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2361 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2362 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2363 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2364 | } |
| 2365 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2366 | if (spec->no_analog) |
| 2367 | return 0; |
| 2368 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2369 | /* If the use of more than one ADC is requested for the current |
| 2370 | * model, configure a second analog capture-only PCM. |
| 2371 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2372 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2373 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2374 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2375 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2376 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2377 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2378 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2379 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2380 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2381 | p = spec->stream_analog_alt_playback; |
| 2382 | if (!p) |
| 2383 | p = &alc_pcm_analog_alt_playback; |
| 2384 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2385 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2386 | spec->alt_dac_nid; |
| 2387 | } else { |
| 2388 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2389 | alc_pcm_null_stream; |
| 2390 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2391 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2392 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2393 | p = spec->stream_analog_alt_capture; |
| 2394 | if (!p) |
| 2395 | p = &alc_pcm_analog_alt_capture; |
| 2396 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2397 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2398 | spec->adc_nids[1]; |
| 2399 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2400 | spec->num_adc_nids - 1; |
| 2401 | } else { |
| 2402 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2403 | alc_pcm_null_stream; |
| 2404 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2405 | } |
| 2406 | } |
| 2407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | return 0; |
| 2409 | } |
| 2410 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2411 | static inline void alc_shutup(struct hda_codec *codec) |
| 2412 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2413 | struct alc_spec *spec = codec->spec; |
| 2414 | |
| 2415 | if (spec && spec->shutup) |
| 2416 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2417 | snd_hda_shutup_pins(codec); |
| 2418 | } |
| 2419 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2420 | static void alc_free_kctls(struct hda_codec *codec) |
| 2421 | { |
| 2422 | struct alc_spec *spec = codec->spec; |
| 2423 | |
| 2424 | if (spec->kctls.list) { |
| 2425 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2426 | int i; |
| 2427 | for (i = 0; i < spec->kctls.used; i++) |
| 2428 | kfree(kctl[i].name); |
| 2429 | } |
| 2430 | snd_array_free(&spec->kctls); |
| 2431 | } |
| 2432 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2433 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2434 | { |
| 2435 | struct alc_spec *spec = codec->spec; |
| 2436 | if (spec->bind_ctls.list) { |
| 2437 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2438 | int i; |
| 2439 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2440 | kfree(ctl[i]); |
| 2441 | } |
| 2442 | snd_array_free(&spec->bind_ctls); |
| 2443 | } |
| 2444 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | static void alc_free(struct hda_codec *codec) |
| 2446 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2447 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2448 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2449 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2450 | return; |
| 2451 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2452 | alc_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2453 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2454 | alc_free_bind_ctls(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2455 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2456 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | } |
| 2458 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2459 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2460 | static void alc_power_eapd(struct hda_codec *codec) |
| 2461 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2462 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2463 | } |
| 2464 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2465 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
| 2466 | { |
| 2467 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2468 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2469 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2470 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2471 | return 0; |
| 2472 | } |
| 2473 | #endif |
| 2474 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2475 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2476 | static int alc_resume(struct hda_codec *codec) |
| 2477 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2478 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2479 | codec->patch_ops.init(codec); |
| 2480 | snd_hda_codec_resume_amp(codec); |
| 2481 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2482 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2483 | return 0; |
| 2484 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2485 | #endif |
| 2486 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2487 | /* |
| 2488 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2489 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | .build_controls = alc_build_controls, |
| 2491 | .build_pcms = alc_build_pcms, |
| 2492 | .init = alc_init, |
| 2493 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2494 | .unsol_event = alc_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2495 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2496 | .resume = alc_resume, |
| 2497 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2498 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2499 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2500 | .check_power_status = alc_check_power_status, |
| 2501 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2502 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2503 | }; |
| 2504 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2505 | /* replace the codec chip_name with the given string */ |
| 2506 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2507 | { |
| 2508 | kfree(codec->chip_name); |
| 2509 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2510 | if (!codec->chip_name) { |
| 2511 | alc_free(codec); |
| 2512 | return -ENOMEM; |
| 2513 | } |
| 2514 | return 0; |
| 2515 | } |
| 2516 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2517 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2518 | * Rename codecs appropriately from COEF value |
| 2519 | */ |
| 2520 | struct alc_codec_rename_table { |
| 2521 | unsigned int vendor_id; |
| 2522 | unsigned short coef_mask; |
| 2523 | unsigned short coef_bits; |
| 2524 | const char *name; |
| 2525 | }; |
| 2526 | |
| 2527 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2528 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2529 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2530 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2531 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2532 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2533 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2534 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
| 2535 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2536 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2537 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2538 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2539 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2540 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2541 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2542 | { } /* terminator */ |
| 2543 | }; |
| 2544 | |
| 2545 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2546 | { |
| 2547 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2548 | |
| 2549 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2550 | if (p->vendor_id != codec->vendor_id) |
| 2551 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2552 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2553 | return alc_codec_rename(codec, p->name); |
| 2554 | } |
| 2555 | return 0; |
| 2556 | } |
| 2557 | |
| 2558 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2559 | * Automatic parse of I/O pins from the BIOS configuration |
| 2560 | */ |
| 2561 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2562 | enum { |
| 2563 | ALC_CTL_WIDGET_VOL, |
| 2564 | ALC_CTL_WIDGET_MUTE, |
| 2565 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2566 | ALC_CTL_BIND_VOL, |
| 2567 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2568 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2569 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2570 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2571 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2572 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2573 | HDA_BIND_VOL(NULL, 0), |
| 2574 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2575 | }; |
| 2576 | |
| 2577 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2578 | 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] | 2579 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2580 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2581 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2582 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2583 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2584 | if (!knew) |
| 2585 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2586 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2587 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2588 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2589 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2590 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2591 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2592 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2593 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2594 | return 0; |
| 2595 | } |
| 2596 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2597 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2598 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2599 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2600 | { |
| 2601 | char name[32]; |
| 2602 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2603 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2604 | } |
| 2605 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2606 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2607 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2608 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2609 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2610 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2611 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2612 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2613 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2614 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2615 | static const char * const channel_name[4] = { |
| 2616 | "Front", "Surround", "CLFE", "Side" |
| 2617 | }; |
| 2618 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2619 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2620 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2621 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2622 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2623 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2624 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2625 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2626 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2627 | return "Master"; |
| 2628 | |
| 2629 | switch (cfg->line_out_type) { |
| 2630 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2631 | if (cfg->line_outs == 1) |
| 2632 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2633 | if (cfg->line_outs == 2) |
| 2634 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2635 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2636 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2637 | /* for multi-io case, only the primary out */ |
| 2638 | if (ch && spec->multi_ios) |
| 2639 | break; |
| 2640 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2641 | return "Headphone"; |
| 2642 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2643 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2644 | return "PCM"; |
| 2645 | break; |
| 2646 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2647 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2648 | return "PCM"; |
| 2649 | |
| 2650 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2651 | } |
| 2652 | |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2653 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2654 | /* add the powersave loopback-list entry */ |
| 2655 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2656 | { |
| 2657 | struct hda_amp_list *list; |
| 2658 | |
| 2659 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2660 | return; |
| 2661 | list = spec->loopback_list + spec->num_loopbacks; |
| 2662 | list->nid = mix; |
| 2663 | list->dir = HDA_INPUT; |
| 2664 | list->idx = idx; |
| 2665 | spec->num_loopbacks++; |
| 2666 | spec->loopback.amplist = spec->loopback_list; |
| 2667 | } |
| 2668 | #else |
| 2669 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2670 | #endif |
| 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; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2687 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2688 | return 0; |
| 2689 | } |
| 2690 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2691 | static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2692 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2693 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2694 | return (pincap & AC_PINCAP_IN) != 0; |
| 2695 | } |
| 2696 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2697 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2698 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2699 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2700 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2701 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2702 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2703 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2704 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2705 | int i, nums = 0; |
| 2706 | |
| 2707 | nid = codec->start_nid; |
| 2708 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2709 | hda_nid_t src; |
| 2710 | const hda_nid_t *list; |
| 2711 | unsigned int caps = get_wcaps(codec, nid); |
| 2712 | int type = get_wcaps_type(caps); |
| 2713 | |
| 2714 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2715 | continue; |
| 2716 | adc_nids[nums] = nid; |
| 2717 | cap_nids[nums] = nid; |
| 2718 | src = nid; |
| 2719 | for (;;) { |
| 2720 | int n; |
| 2721 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2722 | if (type == AC_WID_PIN) |
| 2723 | break; |
| 2724 | if (type == AC_WID_AUD_SEL) { |
| 2725 | cap_nids[nums] = src; |
| 2726 | break; |
| 2727 | } |
| 2728 | n = snd_hda_get_conn_list(codec, src, &list); |
| 2729 | if (n > 1) { |
| 2730 | cap_nids[nums] = src; |
| 2731 | break; |
| 2732 | } else if (n != 1) |
| 2733 | break; |
| 2734 | src = *list; |
| 2735 | } |
| 2736 | if (++nums >= max_nums) |
| 2737 | break; |
| 2738 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2739 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2740 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2741 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2742 | return nums; |
| 2743 | } |
| 2744 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2745 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2746 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2747 | { |
| 2748 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2749 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2750 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2751 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2752 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2753 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2754 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2755 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2756 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2757 | if (num_adcs < 0) |
| 2758 | return 0; |
| 2759 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2760 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2761 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2762 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2763 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2764 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2765 | if (!alc_is_input_pin(codec, pin)) |
| 2766 | continue; |
| 2767 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2768 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2769 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2770 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2771 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2772 | type_idx++; |
| 2773 | else |
| 2774 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2775 | prev_label = label; |
| 2776 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2777 | if (mixer) { |
| 2778 | idx = get_connection_index(codec, mixer, pin); |
| 2779 | if (idx >= 0) { |
| 2780 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2781 | label, type_idx, |
| 2782 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2783 | if (err < 0) |
| 2784 | return err; |
| 2785 | } |
| 2786 | } |
| 2787 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2788 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2789 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2790 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2791 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2792 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2793 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2794 | break; |
| 2795 | } |
| 2796 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2797 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2798 | |
| 2799 | spec->num_mux_defs = 1; |
| 2800 | spec->input_mux = imux; |
| 2801 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2802 | return 0; |
| 2803 | } |
| 2804 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2805 | /* create a shared input with the headphone out */ |
| 2806 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2807 | { |
| 2808 | struct alc_spec *spec = codec->spec; |
| 2809 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2810 | unsigned int defcfg; |
| 2811 | hda_nid_t nid; |
| 2812 | |
| 2813 | /* only one internal input pin? */ |
| 2814 | if (cfg->num_inputs != 1) |
| 2815 | return 0; |
| 2816 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2817 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2818 | return 0; |
| 2819 | |
| 2820 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2821 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2822 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2823 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2824 | else |
| 2825 | return 0; /* both not available */ |
| 2826 | |
| 2827 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2828 | return 0; /* no input */ |
| 2829 | |
| 2830 | cfg->inputs[1].pin = nid; |
| 2831 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2832 | cfg->num_inputs = 2; |
| 2833 | spec->shared_mic_hp = 1; |
| 2834 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2835 | return 0; |
| 2836 | } |
| 2837 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2838 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2839 | unsigned int pin_type) |
| 2840 | { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2841 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2842 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2843 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2844 | 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] | 2845 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2846 | } |
| 2847 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2848 | static int get_pin_type(int line_out_type) |
| 2849 | { |
| 2850 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2851 | return PIN_HP; |
| 2852 | else |
| 2853 | return PIN_OUT; |
| 2854 | } |
| 2855 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2856 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2857 | { |
| 2858 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2859 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2860 | int i; |
| 2861 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2862 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2863 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2864 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2865 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2866 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2867 | snd_hda_codec_write(codec, nid, 0, |
| 2868 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2869 | AMP_OUT_MUTE); |
| 2870 | } |
| 2871 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2872 | |
| 2873 | /* mute all loopback inputs */ |
| 2874 | if (spec->mixer_nid) { |
| 2875 | int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); |
| 2876 | for (i = 0; i < nums; i++) |
| 2877 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2878 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2879 | AMP_IN_MUTE(i)); |
| 2880 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2881 | } |
| 2882 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2883 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2884 | 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] | 2885 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2886 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2887 | int i, num; |
| 2888 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2889 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2890 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2891 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2892 | for (i = 0; i < num; i++) { |
| 2893 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2894 | return list[i]; |
| 2895 | } |
| 2896 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2897 | } |
| 2898 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2899 | /* go down to the selector widget before the mixer */ |
| 2900 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2901 | { |
| 2902 | hda_nid_t srcs[5]; |
| 2903 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2904 | ARRAY_SIZE(srcs)); |
| 2905 | if (num != 1 || |
| 2906 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2907 | return pin; |
| 2908 | return srcs[0]; |
| 2909 | } |
| 2910 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2911 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2912 | 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] | 2913 | hda_nid_t dac) |
| 2914 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2915 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2916 | int i, num; |
| 2917 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2918 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2919 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2920 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2921 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2922 | return mix[i]; |
| 2923 | } |
| 2924 | return 0; |
| 2925 | } |
| 2926 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2927 | /* select the connection from pin to DAC if needed */ |
| 2928 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2929 | hda_nid_t dac) |
| 2930 | { |
| 2931 | hda_nid_t mix[5]; |
| 2932 | int i, num; |
| 2933 | |
| 2934 | pin = alc_go_down_to_selector(codec, pin); |
| 2935 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2936 | if (num < 2) |
| 2937 | return 0; |
| 2938 | for (i = 0; i < num; i++) { |
| 2939 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2940 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2941 | AC_VERB_SET_CONNECT_SEL, i); |
| 2942 | return 0; |
| 2943 | } |
| 2944 | } |
| 2945 | return 0; |
| 2946 | } |
| 2947 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2948 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2949 | { |
| 2950 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2951 | int i; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2952 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
| 2953 | ARRAY_SIZE(spec->private_dac_nids)) || |
| 2954 | found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2955 | ARRAY_SIZE(spec->multiout.hp_out_nid)) || |
| 2956 | found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2957 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2958 | return true; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2959 | for (i = 0; i < spec->multi_ios; i++) { |
| 2960 | if (spec->multi_io[i].dac == nid) |
| 2961 | return true; |
| 2962 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2963 | return false; |
| 2964 | } |
| 2965 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2966 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2967 | 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] | 2968 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2969 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2970 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2971 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2972 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2973 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2974 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2975 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2976 | if (!nid) |
| 2977 | continue; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2978 | if (!alc_is_dac_already_used(codec, nid)) |
| 2979 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2980 | } |
| 2981 | return 0; |
| 2982 | } |
| 2983 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2984 | /* check whether the DAC is reachable from the pin */ |
| 2985 | static bool alc_auto_is_dac_reachable(struct hda_codec *codec, |
| 2986 | hda_nid_t pin, hda_nid_t dac) |
| 2987 | { |
| 2988 | hda_nid_t srcs[5]; |
| 2989 | int i, num; |
| 2990 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 2991 | if (!pin || !dac) |
| 2992 | return false; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2993 | pin = alc_go_down_to_selector(codec, pin); |
| 2994 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
| 2995 | for (i = 0; i < num; i++) { |
| 2996 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 2997 | if (nid == dac) |
| 2998 | return true; |
| 2999 | } |
| 3000 | return false; |
| 3001 | } |
| 3002 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3003 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 3004 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3005 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3006 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3007 | hda_nid_t nid, nid_found, srcs[5]; |
| 3008 | int i, num = snd_hda_get_connections(codec, sel, srcs, |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3009 | ARRAY_SIZE(srcs)); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3010 | if (num == 1) |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3011 | return alc_auto_look_for_dac(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3012 | nid_found = 0; |
| 3013 | for (i = 0; i < num; i++) { |
| 3014 | if (srcs[i] == spec->mixer_nid) |
| 3015 | continue; |
| 3016 | nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 3017 | if (nid && !alc_is_dac_already_used(codec, nid)) { |
| 3018 | if (nid_found) |
| 3019 | return 0; |
| 3020 | nid_found = nid; |
| 3021 | } |
| 3022 | } |
| 3023 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3024 | } |
| 3025 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3026 | /* mark up volume and mute control NIDs: used during badness parsing and |
| 3027 | * at creating actual controls |
| 3028 | */ |
| 3029 | static inline unsigned int get_ctl_pos(unsigned int data) |
| 3030 | { |
| 3031 | hda_nid_t nid = get_amp_nid_(data); |
| 3032 | unsigned int dir; |
| 3033 | if (snd_BUG_ON(nid >= MAX_VOL_NIDS)) |
| 3034 | return 0; |
| 3035 | dir = get_amp_direction_(data); |
| 3036 | return (nid << 1) | dir; |
| 3037 | } |
| 3038 | |
| 3039 | #define is_ctl_used(bits, data) \ |
| 3040 | test_bit(get_ctl_pos(data), bits) |
| 3041 | #define mark_ctl_usage(bits, data) \ |
| 3042 | set_bit(get_ctl_pos(data), bits) |
| 3043 | |
| 3044 | static void clear_vol_marks(struct hda_codec *codec) |
| 3045 | { |
| 3046 | struct alc_spec *spec = codec->spec; |
| 3047 | memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls)); |
| 3048 | memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls)); |
| 3049 | } |
| 3050 | |
| 3051 | /* badness definition */ |
| 3052 | enum { |
| 3053 | /* No primary DAC is found for the main output */ |
| 3054 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3055 | /* No DAC is found for the extra output */ |
| 3056 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3057 | /* No possible multi-ios */ |
| 3058 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3059 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3060 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3061 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3062 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3063 | /* Primary DAC shared with main surrounds */ |
| 3064 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3065 | /* Primary DAC shared with main CLFE */ |
| 3066 | BAD_SHARED_CLFE = 0x10, |
| 3067 | /* Primary DAC shared with extra surrounds */ |
| 3068 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3069 | /* Volume widget is shared */ |
| 3070 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3071 | }; |
| 3072 | |
| 3073 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3074 | hda_nid_t pin, hda_nid_t dac); |
| 3075 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3076 | hda_nid_t pin, hda_nid_t dac); |
| 3077 | |
| 3078 | static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin, |
| 3079 | hda_nid_t dac) |
| 3080 | { |
| 3081 | struct alc_spec *spec = codec->spec; |
| 3082 | hda_nid_t nid; |
| 3083 | unsigned int val; |
| 3084 | int badness = 0; |
| 3085 | |
| 3086 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3087 | if (nid) { |
| 3088 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3089 | if (is_ctl_used(spec->vol_ctls, nid)) |
| 3090 | badness += BAD_SHARED_VOL; |
| 3091 | else |
| 3092 | mark_ctl_usage(spec->vol_ctls, val); |
| 3093 | } else |
| 3094 | badness += BAD_SHARED_VOL; |
| 3095 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3096 | if (nid) { |
| 3097 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3098 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) |
| 3099 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3100 | else |
| 3101 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
| 3102 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3103 | badness += BAD_SHARED_VOL; |
| 3104 | else |
| 3105 | mark_ctl_usage(spec->sw_ctls, val); |
| 3106 | } else |
| 3107 | badness += BAD_SHARED_VOL; |
| 3108 | return badness; |
| 3109 | } |
| 3110 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3111 | struct badness_table { |
| 3112 | int no_primary_dac; /* no primary DAC */ |
| 3113 | int no_dac; /* no secondary DACs */ |
| 3114 | int shared_primary; /* primary DAC is shared with main output */ |
| 3115 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3116 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3117 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3118 | }; |
| 3119 | |
| 3120 | static struct badness_table main_out_badness = { |
| 3121 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3122 | .no_dac = BAD_NO_DAC, |
| 3123 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3124 | .shared_surr = BAD_SHARED_SURROUND, |
| 3125 | .shared_clfe = BAD_SHARED_CLFE, |
| 3126 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3127 | }; |
| 3128 | |
| 3129 | static struct badness_table extra_out_badness = { |
| 3130 | .no_primary_dac = BAD_NO_DAC, |
| 3131 | .no_dac = BAD_NO_DAC, |
| 3132 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3133 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3134 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3135 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3136 | }; |
| 3137 | |
| 3138 | /* try to assign DACs to pins and return the resultant badness */ |
| 3139 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3140 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3141 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3142 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3143 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3144 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3145 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3146 | int badness = 0; |
| 3147 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3148 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3149 | if (!num_outs) |
| 3150 | return 0; |
| 3151 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3152 | for (i = 0; i < num_outs; i++) { |
| 3153 | hda_nid_t pin = pins[i]; |
| 3154 | if (!dacs[i]) |
| 3155 | dacs[i] = alc_auto_look_for_dac(codec, pin); |
| 3156 | if (!dacs[i] && !i) { |
| 3157 | for (j = 1; j < num_outs; j++) { |
| 3158 | if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) { |
| 3159 | dacs[0] = dacs[j]; |
| 3160 | dacs[j] = 0; |
| 3161 | break; |
| 3162 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3163 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3164 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3165 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3166 | if (!dac) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3167 | if (alc_auto_is_dac_reachable(codec, pin, dacs[0])) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3168 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3169 | else if (cfg->line_outs > i && |
| 3170 | alc_auto_is_dac_reachable(codec, pin, |
| 3171 | spec->private_dac_nids[i])) |
| 3172 | dac = spec->private_dac_nids[i]; |
| 3173 | if (dac) { |
| 3174 | if (!i) |
| 3175 | badness += bad->shared_primary; |
| 3176 | else if (i == 1) |
| 3177 | badness += bad->shared_surr; |
| 3178 | else |
| 3179 | badness += bad->shared_clfe; |
| 3180 | } else if (alc_auto_is_dac_reachable(codec, pin, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3181 | spec->private_dac_nids[0])) { |
| 3182 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3183 | badness += bad->shared_surr_main; |
| 3184 | } else if (!i) |
| 3185 | badness += bad->no_primary_dac; |
| 3186 | else |
| 3187 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3188 | } |
| 3189 | if (dac) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3190 | badness += eval_shared_vol_badness(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3191 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3192 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3193 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3194 | } |
| 3195 | |
| 3196 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3197 | hda_nid_t reference_pin, |
| 3198 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3199 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3200 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3201 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3202 | { |
| 3203 | int i; |
| 3204 | bool found = false; |
| 3205 | for (i = 0; i < outs; i++) { |
| 3206 | if (dacs[i]) |
| 3207 | continue; |
| 3208 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 3209 | if (dacs[i]) |
| 3210 | found = true; |
| 3211 | } |
| 3212 | return found; |
| 3213 | } |
| 3214 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3215 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3216 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3217 | bool fill_hardwired, |
| 3218 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3219 | { |
| 3220 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3221 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3222 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3223 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3224 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3225 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3226 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3227 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3228 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3229 | memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3230 | spec->multi_ios = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3231 | clear_vol_marks(codec); |
| 3232 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3233 | |
| 3234 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3235 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3236 | bool mapped; |
| 3237 | do { |
| 3238 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3239 | cfg->line_out_pins, |
| 3240 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3241 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3242 | cfg->hp_pins, |
| 3243 | spec->multiout.hp_out_nid); |
| 3244 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3245 | cfg->speaker_pins, |
| 3246 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3247 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3248 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3249 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3250 | if (!err) |
| 3251 | mapped = true; |
| 3252 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3253 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3254 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3255 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3256 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3257 | spec->private_dac_nids, |
| 3258 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3259 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3260 | /* re-count num_dacs and squash invalid entries */ |
| 3261 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3262 | for (i = 0; i < cfg->line_outs; i++) { |
| 3263 | if (spec->private_dac_nids[i]) |
| 3264 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3265 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3266 | memmove(spec->private_dac_nids + i, |
| 3267 | spec->private_dac_nids + i + 1, |
| 3268 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3269 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3270 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3271 | } |
| 3272 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3273 | if (fill_mio_first && |
| 3274 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3275 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3276 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3277 | if (err < 0) |
| 3278 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3279 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3280 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3281 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3282 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3283 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3284 | spec->multiout.hp_out_nid, |
| 3285 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3286 | if (err < 0) |
| 3287 | return err; |
| 3288 | badness += err; |
| 3289 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3290 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3291 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3292 | cfg->speaker_pins, |
| 3293 | spec->multiout.extra_out_nid, |
| 3294 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3295 | if (err < 0) |
| 3296 | return err; |
| 3297 | badness += err; |
| 3298 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3299 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3300 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3301 | if (err < 0) |
| 3302 | return err; |
| 3303 | badness += err; |
| 3304 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3305 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3306 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3307 | int offset = 0; |
| 3308 | if (cfg->line_outs >= 3) |
| 3309 | offset = 1; |
| 3310 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3311 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3312 | if (err < 0) |
| 3313 | return err; |
| 3314 | badness += err; |
| 3315 | } |
| 3316 | |
| 3317 | if (spec->multi_ios == 2) { |
| 3318 | for (i = 0; i < 2; i++) |
| 3319 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3320 | spec->multi_io[i].dac; |
| 3321 | spec->ext_channel_count = 2; |
| 3322 | } else if (spec->multi_ios) { |
| 3323 | spec->multi_ios = 0; |
| 3324 | badness += BAD_MULTI_IO; |
| 3325 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3326 | |
| 3327 | return badness; |
| 3328 | } |
| 3329 | |
| 3330 | #define DEBUG_BADNESS |
| 3331 | |
| 3332 | #ifdef DEBUG_BADNESS |
| 3333 | #define debug_badness snd_printdd |
| 3334 | #else |
| 3335 | #define debug_badness(...) |
| 3336 | #endif |
| 3337 | |
| 3338 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3339 | { |
| 3340 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3341 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3342 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3343 | spec->multiout.dac_nids[0], |
| 3344 | spec->multiout.dac_nids[1], |
| 3345 | spec->multiout.dac_nids[2], |
| 3346 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3347 | if (spec->multi_ios > 0) |
| 3348 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3349 | spec->multi_ios, |
| 3350 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3351 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3352 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3353 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3354 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3355 | spec->multiout.hp_out_nid[0], |
| 3356 | spec->multiout.hp_out_nid[1], |
| 3357 | spec->multiout.hp_out_nid[2], |
| 3358 | spec->multiout.hp_out_nid[3]); |
| 3359 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3360 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3361 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3362 | spec->multiout.extra_out_nid[0], |
| 3363 | spec->multiout.extra_out_nid[1], |
| 3364 | spec->multiout.extra_out_nid[2], |
| 3365 | spec->multiout.extra_out_nid[3]); |
| 3366 | } |
| 3367 | |
| 3368 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3369 | { |
| 3370 | struct alc_spec *spec = codec->spec; |
| 3371 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3372 | struct auto_pin_cfg *best_cfg; |
| 3373 | int best_badness = INT_MAX; |
| 3374 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3375 | bool fill_hardwired = true, fill_mio_first = true; |
| 3376 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3377 | bool hp_spk_swapped = false; |
| 3378 | |
| 3379 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3380 | if (!best_cfg) |
| 3381 | return -ENOMEM; |
| 3382 | *best_cfg = *cfg; |
| 3383 | |
| 3384 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3385 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3386 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3387 | if (badness < 0) { |
| 3388 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3389 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3390 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3391 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3392 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3393 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3394 | debug_show_configs(spec, cfg); |
| 3395 | if (badness < best_badness) { |
| 3396 | best_badness = badness; |
| 3397 | *best_cfg = *cfg; |
| 3398 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3399 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3400 | } |
| 3401 | if (!badness) |
| 3402 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3403 | fill_mio_first = !fill_mio_first; |
| 3404 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3405 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3406 | fill_hardwired = !fill_hardwired; |
| 3407 | if (!fill_hardwired) |
| 3408 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3409 | if (hp_spk_swapped) |
| 3410 | break; |
| 3411 | hp_spk_swapped = true; |
| 3412 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3413 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3414 | cfg->hp_outs = cfg->line_outs; |
| 3415 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3416 | sizeof(cfg->hp_pins)); |
| 3417 | cfg->line_outs = cfg->speaker_outs; |
| 3418 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3419 | sizeof(cfg->speaker_pins)); |
| 3420 | cfg->speaker_outs = 0; |
| 3421 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3422 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3423 | fill_hardwired = true; |
| 3424 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3425 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3426 | if (cfg->hp_outs > 0 && |
| 3427 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3428 | cfg->speaker_outs = cfg->line_outs; |
| 3429 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3430 | sizeof(cfg->speaker_pins)); |
| 3431 | cfg->line_outs = cfg->hp_outs; |
| 3432 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3433 | sizeof(cfg->hp_pins)); |
| 3434 | cfg->hp_outs = 0; |
| 3435 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3436 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3437 | fill_hardwired = true; |
| 3438 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3439 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3440 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3441 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3442 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3443 | if (badness) { |
| 3444 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3445 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3446 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3447 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3448 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3449 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3450 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3451 | if (cfg->line_out_pins[0]) |
| 3452 | spec->vmaster_nid = |
| 3453 | alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], |
| 3454 | spec->multiout.dac_nids[0]); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3455 | |
| 3456 | /* clear the bitmap flags for creating controls */ |
| 3457 | clear_vol_marks(codec); |
| 3458 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3459 | return 0; |
| 3460 | } |
| 3461 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3462 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3463 | const char *pfx, int cidx, |
| 3464 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3465 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3466 | struct alc_spec *spec = codec->spec; |
| 3467 | unsigned int val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3468 | if (!nid) |
| 3469 | return 0; |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3470 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3471 | if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ |
| 3472 | return 0; |
| 3473 | mark_ctl_usage(spec->vol_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3474 | 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] | 3475 | val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3476 | } |
| 3477 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3478 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3479 | const char *pfx, int cidx, |
| 3480 | hda_nid_t nid) |
| 3481 | { |
| 3482 | int chs = 1; |
| 3483 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3484 | chs = 3; |
| 3485 | return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); |
| 3486 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3487 | |
| 3488 | /* create a mute-switch for the given mixer widget; |
| 3489 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3490 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3491 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3492 | const char *pfx, int cidx, |
| 3493 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3494 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3495 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3496 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3497 | int type; |
| 3498 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3499 | if (!nid) |
| 3500 | return 0; |
| 3501 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3502 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3503 | type = ALC_CTL_WIDGET_MUTE; |
| 3504 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3505 | } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3506 | type = ALC_CTL_WIDGET_MUTE; |
| 3507 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3508 | } else { |
| 3509 | type = ALC_CTL_BIND_MUTE; |
| 3510 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3511 | } |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3512 | if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ |
| 3513 | return 0; |
| 3514 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3515 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3516 | } |
| 3517 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3518 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
| 3519 | int cidx, hda_nid_t nid) |
| 3520 | { |
| 3521 | int chs = 1; |
| 3522 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3523 | chs = 3; |
| 3524 | return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); |
| 3525 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3526 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3527 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3528 | hda_nid_t pin, hda_nid_t dac) |
| 3529 | { |
| 3530 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3531 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3532 | return pin; |
| 3533 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3534 | return mix; |
| 3535 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3536 | return dac; |
| 3537 | return 0; |
| 3538 | } |
| 3539 | |
| 3540 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3541 | hda_nid_t pin, hda_nid_t dac) |
| 3542 | { |
| 3543 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3544 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3545 | return dac; |
| 3546 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3547 | return mix; |
| 3548 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3549 | return pin; |
| 3550 | return 0; |
| 3551 | } |
| 3552 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3553 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3554 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3555 | const struct auto_pin_cfg *cfg) |
| 3556 | { |
| 3557 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3558 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3559 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3560 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3561 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3562 | noutputs += spec->multi_ios; |
| 3563 | |
| 3564 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3565 | const char *name; |
| 3566 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3567 | hda_nid_t dac, pin; |
| 3568 | hda_nid_t sw, vol; |
| 3569 | |
| 3570 | dac = spec->multiout.dac_nids[i]; |
| 3571 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3572 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3573 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3574 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3575 | index = 0; |
| 3576 | name = channel_name[i]; |
| 3577 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3578 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3579 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3580 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3581 | |
| 3582 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3583 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3584 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3585 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3586 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3587 | if (err < 0) |
| 3588 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3589 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3590 | if (err < 0) |
| 3591 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3592 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3593 | if (err < 0) |
| 3594 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3595 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3596 | if (err < 0) |
| 3597 | return err; |
| 3598 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3599 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3600 | if (err < 0) |
| 3601 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3602 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3603 | if (err < 0) |
| 3604 | return err; |
| 3605 | } |
| 3606 | } |
| 3607 | return 0; |
| 3608 | } |
| 3609 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3610 | 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] | 3611 | hda_nid_t dac, const char *pfx, |
| 3612 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3613 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3614 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3615 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3616 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3617 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3618 | if (!dac) { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3619 | unsigned int val; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3620 | /* the corresponding DAC is already occupied */ |
| 3621 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3622 | return 0; /* no way */ |
| 3623 | /* create a switch only */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3624 | val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); |
| 3625 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3626 | return 0; /* already created */ |
| 3627 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3628 | 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] | 3629 | } |
| 3630 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3631 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3632 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3633 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3634 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3635 | return err; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3636 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3637 | if (err < 0) |
| 3638 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3639 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3640 | } |
| 3641 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3642 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3643 | unsigned int nums, |
| 3644 | struct hda_ctl_ops *ops) |
| 3645 | { |
| 3646 | struct alc_spec *spec = codec->spec; |
| 3647 | struct hda_bind_ctls **ctlp, *ctl; |
| 3648 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3649 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3650 | if (!ctlp) |
| 3651 | return NULL; |
| 3652 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3653 | *ctlp = ctl; |
| 3654 | if (ctl) |
| 3655 | ctl->ops = ops; |
| 3656 | return ctl; |
| 3657 | } |
| 3658 | |
| 3659 | /* add playback controls for speaker and HP outputs */ |
| 3660 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3661 | const hda_nid_t *pins, |
| 3662 | const hda_nid_t *dacs, |
| 3663 | const char *pfx) |
| 3664 | { |
| 3665 | struct alc_spec *spec = codec->spec; |
| 3666 | struct hda_bind_ctls *ctl; |
| 3667 | char name[32]; |
| 3668 | int i, n, err; |
| 3669 | |
| 3670 | if (!num_pins || !pins[0]) |
| 3671 | return 0; |
| 3672 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3673 | if (num_pins == 1) { |
| 3674 | hda_nid_t dac = *dacs; |
| 3675 | if (!dac) |
| 3676 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3677 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3678 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3679 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3680 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3681 | hda_nid_t dac; |
| 3682 | if (dacs[num_pins - 1]) |
| 3683 | dac = dacs[i]; /* with individual volumes */ |
| 3684 | else |
| 3685 | dac = 0; |
| 3686 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3687 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3688 | "Bass Speaker", 0); |
| 3689 | } else if (num_pins >= 3) { |
| 3690 | snprintf(name, sizeof(name), "%s %s", |
| 3691 | pfx, channel_name[i]); |
| 3692 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3693 | name, 0); |
| 3694 | } else { |
| 3695 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3696 | pfx, i); |
| 3697 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3698 | if (err < 0) |
| 3699 | return err; |
| 3700 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3701 | if (dacs[num_pins - 1]) |
| 3702 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3703 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3704 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3705 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3706 | if (!ctl) |
| 3707 | return -ENOMEM; |
| 3708 | n = 0; |
| 3709 | for (i = 0; i < num_pins; i++) { |
| 3710 | hda_nid_t vol; |
| 3711 | if (!pins[i] || !dacs[i]) |
| 3712 | continue; |
| 3713 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3714 | if (vol) |
| 3715 | ctl->values[n++] = |
| 3716 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3717 | } |
| 3718 | if (n) { |
| 3719 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3720 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3721 | if (err < 0) |
| 3722 | return err; |
| 3723 | } |
| 3724 | return 0; |
| 3725 | } |
| 3726 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3727 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3728 | { |
| 3729 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3730 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3731 | spec->autocfg.hp_pins, |
| 3732 | spec->multiout.hp_out_nid, |
| 3733 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3734 | } |
| 3735 | |
| 3736 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3737 | { |
| 3738 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3739 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3740 | spec->autocfg.speaker_pins, |
| 3741 | spec->multiout.extra_out_nid, |
| 3742 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3743 | } |
| 3744 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3745 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3746 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3747 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3748 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3749 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3750 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3751 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3752 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3753 | alc_set_pin_output(codec, pin, pin_type); |
| 3754 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3755 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3756 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3757 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3758 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3759 | mix = srcs[i]; |
| 3760 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3761 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3762 | if (!mix) |
| 3763 | return; |
| 3764 | |
| 3765 | /* need the manual connection? */ |
| 3766 | if (num > 1) |
| 3767 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3768 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3769 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3770 | 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] | 3771 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3772 | 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] | 3773 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3774 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3775 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3776 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3777 | if (nid) |
| 3778 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3779 | AMP_OUT_ZERO); |
Takashi Iwai | 43dea22 | 2011-11-06 11:25:34 +0100 | [diff] [blame] | 3780 | |
| 3781 | /* unmute DAC if it's not assigned to a mixer */ |
| 3782 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3783 | if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3784 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3785 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3786 | } |
| 3787 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3788 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3789 | { |
| 3790 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3791 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3792 | int i; |
| 3793 | |
| 3794 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3795 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3796 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3797 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3798 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3799 | } |
| 3800 | } |
| 3801 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3802 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3803 | { |
| 3804 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3805 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3806 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3807 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3808 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3809 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3810 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3811 | pin = spec->autocfg.hp_pins[i]; |
| 3812 | if (!pin) |
| 3813 | break; |
| 3814 | dac = spec->multiout.hp_out_nid[i]; |
| 3815 | if (!dac) { |
| 3816 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3817 | dac = spec->multiout.hp_out_nid[0]; |
| 3818 | else |
| 3819 | dac = spec->multiout.dac_nids[0]; |
| 3820 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3821 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3822 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3823 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3824 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3825 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3826 | pin = spec->autocfg.speaker_pins[i]; |
| 3827 | if (!pin) |
| 3828 | break; |
| 3829 | dac = spec->multiout.extra_out_nid[i]; |
| 3830 | if (!dac) { |
| 3831 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3832 | dac = spec->multiout.extra_out_nid[0]; |
| 3833 | else |
| 3834 | dac = spec->multiout.dac_nids[0]; |
| 3835 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3836 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3837 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3838 | } |
| 3839 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3840 | /* check whether the given pin can be a multi-io pin */ |
| 3841 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 3842 | unsigned int location, hda_nid_t nid) |
| 3843 | { |
| 3844 | unsigned int defcfg, caps; |
| 3845 | |
| 3846 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3847 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3848 | return false; |
| 3849 | if (location && get_defcfg_location(defcfg) != location) |
| 3850 | return false; |
| 3851 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3852 | if (!(caps & AC_PINCAP_OUT)) |
| 3853 | return false; |
| 3854 | return true; |
| 3855 | } |
| 3856 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3857 | /* |
| 3858 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3859 | * |
| 3860 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 3861 | * zero if any pins are filled, non-zero if nothing found. |
| 3862 | * When hardwired is off, try to fill possible input pins, and returns |
| 3863 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3864 | */ |
| 3865 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3866 | hda_nid_t reference_pin, |
| 3867 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3868 | { |
| 3869 | struct alc_spec *spec = codec->spec; |
| 3870 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3871 | int type, i, j, dacs, num_pins, old_pins; |
| 3872 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 3873 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3874 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3875 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3876 | old_pins = spec->multi_ios; |
| 3877 | if (old_pins >= 2) |
| 3878 | goto end_fill; |
| 3879 | |
| 3880 | num_pins = 0; |
| 3881 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3882 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3883 | if (cfg->inputs[i].type != type) |
| 3884 | continue; |
| 3885 | if (can_be_multiio_pin(codec, location, |
| 3886 | cfg->inputs[i].pin)) |
| 3887 | num_pins++; |
| 3888 | } |
| 3889 | } |
| 3890 | if (num_pins < 2) |
| 3891 | goto end_fill; |
| 3892 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3893 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3894 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3895 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3896 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3897 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3898 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3899 | if (cfg->inputs[i].type != type) |
| 3900 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3901 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3902 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3903 | for (j = 0; j < spec->multi_ios; j++) { |
| 3904 | if (nid == spec->multi_io[j].pin) |
| 3905 | break; |
| 3906 | } |
| 3907 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3908 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3909 | |
| 3910 | if (offset && offset + spec->multi_ios < dacs) { |
| 3911 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3912 | if (!alc_auto_is_dac_reachable(codec, nid, dac)) |
| 3913 | dac = 0; |
| 3914 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3915 | if (hardwired) |
| 3916 | dac = get_dac_if_single(codec, nid); |
| 3917 | else if (!dac) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3918 | dac = alc_auto_look_for_dac(codec, nid); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3919 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3920 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3921 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3922 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3923 | spec->multi_io[spec->multi_ios].pin = nid; |
| 3924 | spec->multi_io[spec->multi_ios].dac = dac; |
| 3925 | spec->multi_ios++; |
| 3926 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3927 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3928 | } |
| 3929 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3930 | end_fill: |
| 3931 | if (badness) |
| 3932 | badness = BAD_MULTI_IO; |
| 3933 | if (old_pins == spec->multi_ios) { |
| 3934 | if (hardwired) |
| 3935 | return 1; /* nothing found */ |
| 3936 | else |
| 3937 | return badness; /* no badness if nothing found */ |
| 3938 | } |
| 3939 | if (!hardwired && spec->multi_ios < 2) { |
| 3940 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3941 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3942 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3943 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3944 | return 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3945 | } |
| 3946 | |
| 3947 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3948 | struct snd_ctl_elem_info *uinfo) |
| 3949 | { |
| 3950 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3951 | struct alc_spec *spec = codec->spec; |
| 3952 | |
| 3953 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3954 | uinfo->count = 1; |
| 3955 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3956 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3957 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3958 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3959 | (uinfo->value.enumerated.item + 1) * 2); |
| 3960 | return 0; |
| 3961 | } |
| 3962 | |
| 3963 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3964 | struct snd_ctl_elem_value *ucontrol) |
| 3965 | { |
| 3966 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3967 | struct alc_spec *spec = codec->spec; |
| 3968 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3969 | return 0; |
| 3970 | } |
| 3971 | |
| 3972 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3973 | { |
| 3974 | struct alc_spec *spec = codec->spec; |
| 3975 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3976 | |
| 3977 | if (!spec->multi_io[idx].ctl_in) |
| 3978 | spec->multi_io[idx].ctl_in = |
| 3979 | snd_hda_codec_read(codec, nid, 0, |
| 3980 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3981 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3982 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3983 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3984 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3985 | HDA_AMP_MUTE, 0); |
| 3986 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 3987 | } else { |
| 3988 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3989 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3990 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3991 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 3992 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3993 | } |
| 3994 | return 0; |
| 3995 | } |
| 3996 | |
| 3997 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 3998 | struct snd_ctl_elem_value *ucontrol) |
| 3999 | { |
| 4000 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4001 | struct alc_spec *spec = codec->spec; |
| 4002 | int i, ch; |
| 4003 | |
| 4004 | ch = ucontrol->value.enumerated.item[0]; |
| 4005 | if (ch < 0 || ch > spec->multi_ios) |
| 4006 | return -EINVAL; |
| 4007 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4008 | return 0; |
| 4009 | spec->ext_channel_count = (ch + 1) * 2; |
| 4010 | for (i = 0; i < spec->multi_ios; i++) |
| 4011 | alc_set_multi_io(codec, i, i < ch); |
| 4012 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4013 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 4014 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4015 | return 1; |
| 4016 | } |
| 4017 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4018 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4019 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4020 | .name = "Channel Mode", |
| 4021 | .info = alc_auto_ch_mode_info, |
| 4022 | .get = alc_auto_ch_mode_get, |
| 4023 | .put = alc_auto_ch_mode_put, |
| 4024 | }; |
| 4025 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4026 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4027 | { |
| 4028 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4029 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4030 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4031 | struct snd_kcontrol_new *knew; |
| 4032 | |
| 4033 | knew = alc_kcontrol_new(spec); |
| 4034 | if (!knew) |
| 4035 | return -ENOMEM; |
| 4036 | *knew = alc_auto_channel_mode_enum; |
| 4037 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 4038 | if (!knew->name) |
| 4039 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4040 | } |
| 4041 | return 0; |
| 4042 | } |
| 4043 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4044 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 4045 | * active input pins |
| 4046 | */ |
| 4047 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 4048 | { |
| 4049 | struct alc_spec *spec = codec->spec; |
| 4050 | const struct hda_input_mux *imux; |
| 4051 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4052 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4053 | int i, n, nums; |
| 4054 | |
| 4055 | imux = spec->input_mux; |
| 4056 | if (!imux) |
| 4057 | return; |
| 4058 | if (spec->dyn_adc_switch) |
| 4059 | return; |
| 4060 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4061 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4062 | nums = 0; |
| 4063 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 4064 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
| 4065 | int num_conns = snd_hda_get_conn_list(codec, cap, NULL); |
| 4066 | for (i = 0; i < imux->num_items; i++) { |
| 4067 | hda_nid_t pin = spec->imux_pins[i]; |
| 4068 | if (pin) { |
| 4069 | if (get_connection_index(codec, cap, pin) < 0) |
| 4070 | break; |
| 4071 | } else if (num_conns <= imux->items[i].index) |
| 4072 | break; |
| 4073 | } |
| 4074 | if (i >= imux->num_items) { |
| 4075 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 4076 | capsrc_nids[nums++] = cap; |
| 4077 | } |
| 4078 | } |
| 4079 | if (!nums) { |
| 4080 | /* check whether ADC-switch is possible */ |
| 4081 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4082 | if (spec->shared_mic_hp) { |
| 4083 | spec->shared_mic_hp = 0; |
| 4084 | spec->private_imux[0].num_items = 1; |
| 4085 | goto again; |
| 4086 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4087 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 4088 | " using fallback 0x%x\n", |
| 4089 | codec->chip_name, spec->private_adc_nids[0]); |
| 4090 | spec->num_adc_nids = 1; |
| 4091 | spec->auto_mic = 0; |
| 4092 | return; |
| 4093 | } |
| 4094 | } else if (nums != spec->num_adc_nids) { |
| 4095 | memcpy(spec->private_adc_nids, adc_nids, |
| 4096 | nums * sizeof(hda_nid_t)); |
| 4097 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 4098 | nums * sizeof(hda_nid_t)); |
| 4099 | spec->num_adc_nids = nums; |
| 4100 | } |
| 4101 | |
| 4102 | if (spec->auto_mic) |
| 4103 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4104 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4105 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 4106 | } |
| 4107 | |
| 4108 | /* |
| 4109 | * initialize ADC paths |
| 4110 | */ |
| 4111 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 4112 | { |
| 4113 | struct alc_spec *spec = codec->spec; |
| 4114 | hda_nid_t nid; |
| 4115 | |
| 4116 | nid = spec->adc_nids[adc_idx]; |
| 4117 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4118 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4119 | snd_hda_codec_write(codec, nid, 0, |
| 4120 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4121 | AMP_IN_MUTE(0)); |
| 4122 | return; |
| 4123 | } |
| 4124 | if (!spec->capsrc_nids) |
| 4125 | return; |
| 4126 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4127 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4128 | snd_hda_codec_write(codec, nid, 0, |
| 4129 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4130 | AMP_OUT_MUTE); |
| 4131 | } |
| 4132 | |
| 4133 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4134 | { |
| 4135 | struct alc_spec *spec = codec->spec; |
| 4136 | int c, nums; |
| 4137 | |
| 4138 | for (c = 0; c < spec->num_adc_nids; c++) |
| 4139 | alc_auto_init_adc(codec, c); |
| 4140 | if (spec->dyn_adc_switch) |
| 4141 | nums = 1; |
| 4142 | else |
| 4143 | nums = spec->num_adc_nids; |
| 4144 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 4145 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4146 | } |
| 4147 | |
| 4148 | /* add mic boosts if needed */ |
| 4149 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4150 | { |
| 4151 | struct alc_spec *spec = codec->spec; |
| 4152 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4153 | int i, err; |
| 4154 | int type_idx = 0; |
| 4155 | hda_nid_t nid; |
| 4156 | const char *prev_label = NULL; |
| 4157 | |
| 4158 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4159 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4160 | break; |
| 4161 | nid = cfg->inputs[i].pin; |
| 4162 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4163 | const char *label; |
| 4164 | char boost_label[32]; |
| 4165 | |
| 4166 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4167 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4168 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4169 | if (prev_label && !strcmp(label, prev_label)) |
| 4170 | type_idx++; |
| 4171 | else |
| 4172 | type_idx = 0; |
| 4173 | prev_label = label; |
| 4174 | |
| 4175 | snprintf(boost_label, sizeof(boost_label), |
| 4176 | "%s Boost Volume", label); |
| 4177 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 4178 | boost_label, type_idx, |
| 4179 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 4180 | if (err < 0) |
| 4181 | return err; |
| 4182 | } |
| 4183 | } |
| 4184 | return 0; |
| 4185 | } |
| 4186 | |
| 4187 | /* select or unmute the given capsrc route */ |
| 4188 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4189 | int idx) |
| 4190 | { |
| 4191 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4192 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4193 | HDA_AMP_MUTE, 0); |
| 4194 | } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { |
| 4195 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4196 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4197 | } |
| 4198 | } |
| 4199 | |
| 4200 | /* set the default connection to that pin */ |
| 4201 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4202 | { |
| 4203 | struct alc_spec *spec = codec->spec; |
| 4204 | int i; |
| 4205 | |
| 4206 | if (!pin) |
| 4207 | return 0; |
| 4208 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4209 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4210 | int idx; |
| 4211 | |
| 4212 | idx = get_connection_index(codec, cap, pin); |
| 4213 | if (idx < 0) |
| 4214 | continue; |
| 4215 | select_or_unmute_capsrc(codec, cap, idx); |
| 4216 | return i; /* return the found index */ |
| 4217 | } |
| 4218 | return -1; /* not found */ |
| 4219 | } |
| 4220 | |
| 4221 | /* initialize some special cases for input sources */ |
| 4222 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4223 | { |
| 4224 | struct alc_spec *spec = codec->spec; |
| 4225 | int i; |
| 4226 | |
| 4227 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4228 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4229 | } |
| 4230 | |
| 4231 | /* assign appropriate capture mixers */ |
| 4232 | static void set_capture_mixer(struct hda_codec *codec) |
| 4233 | { |
| 4234 | struct alc_spec *spec = codec->spec; |
| 4235 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4236 | { alc_capture_mixer_nosrc1, |
| 4237 | alc_capture_mixer_nosrc2, |
| 4238 | alc_capture_mixer_nosrc3 }, |
| 4239 | { alc_capture_mixer1, |
| 4240 | alc_capture_mixer2, |
| 4241 | alc_capture_mixer3 }, |
| 4242 | }; |
| 4243 | |
| 4244 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4245 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4246 | if (!spec->capsrc_nids) |
| 4247 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4248 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4249 | return; /* no volume in capsrc, too */ |
| 4250 | spec->vol_in_capsrc = 1; |
| 4251 | } |
| 4252 | |
| 4253 | if (spec->num_adc_nids > 0) { |
| 4254 | int mux = 0; |
| 4255 | int num_adcs = 0; |
| 4256 | |
| 4257 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4258 | mux = 1; |
| 4259 | if (spec->auto_mic) { |
| 4260 | num_adcs = 1; |
| 4261 | mux = 0; |
| 4262 | } else if (spec->dyn_adc_switch) |
| 4263 | num_adcs = 1; |
| 4264 | if (!num_adcs) { |
| 4265 | if (spec->num_adc_nids > 3) |
| 4266 | spec->num_adc_nids = 3; |
| 4267 | else if (!spec->num_adc_nids) |
| 4268 | return; |
| 4269 | num_adcs = spec->num_adc_nids; |
| 4270 | } |
| 4271 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4272 | } |
| 4273 | } |
| 4274 | |
| 4275 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4276 | * standard auto-parser initializations |
| 4277 | */ |
| 4278 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4279 | { |
| 4280 | struct alc_spec *spec = codec->spec; |
| 4281 | alc_auto_init_multi_out(codec); |
| 4282 | alc_auto_init_extra_out(codec); |
| 4283 | alc_auto_init_analog_input(codec); |
| 4284 | alc_auto_init_input_src(codec); |
| 4285 | alc_auto_init_digital(codec); |
| 4286 | if (spec->unsol_event) |
| 4287 | alc_inithook(codec); |
| 4288 | } |
| 4289 | |
| 4290 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4291 | * Digital-beep handlers |
| 4292 | */ |
| 4293 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4294 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4295 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4296 | |
| 4297 | static const struct snd_pci_quirk beep_white_list[] = { |
| 4298 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4299 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4300 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4301 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4302 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4303 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4304 | {} |
| 4305 | }; |
| 4306 | |
| 4307 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4308 | { |
| 4309 | struct alc_spec *spec = codec->spec; |
| 4310 | const struct snd_pci_quirk *q; |
| 4311 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4312 | if (q) |
| 4313 | return q->value; |
| 4314 | return spec->cdefine.enable_pcbeep; |
| 4315 | } |
| 4316 | #else |
| 4317 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4318 | #define has_cdefine_beep(codec) 0 |
| 4319 | #endif |
| 4320 | |
| 4321 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4322 | /* return 1 if successful, 0 if the proper config is not found, |
| 4323 | * or a negative error code |
| 4324 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4325 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4326 | const hda_nid_t *ignore_nids, |
| 4327 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4328 | { |
| 4329 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4330 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4331 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4332 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4333 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4334 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4335 | if (err < 0) |
| 4336 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4337 | if (!cfg->line_outs) { |
| 4338 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4339 | spec->multiout.max_channels = 2; |
| 4340 | spec->no_analog = 1; |
| 4341 | goto dig_only; |
| 4342 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4343 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4344 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4345 | |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4346 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 4347 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4348 | /* use HP as primary out */ |
| 4349 | cfg->speaker_outs = cfg->line_outs; |
| 4350 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4351 | sizeof(cfg->speaker_pins)); |
| 4352 | cfg->line_outs = cfg->hp_outs; |
| 4353 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4354 | cfg->hp_outs = 0; |
| 4355 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4356 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4357 | } |
| 4358 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4359 | err = alc_auto_fill_dac_nids(codec); |
| 4360 | if (err < 0) |
| 4361 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4362 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4363 | if (err < 0) |
| 4364 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4365 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4366 | if (err < 0) |
| 4367 | return err; |
| 4368 | err = alc_auto_create_hp_out(codec); |
| 4369 | if (err < 0) |
| 4370 | return err; |
| 4371 | err = alc_auto_create_speaker_out(codec); |
| 4372 | if (err < 0) |
| 4373 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4374 | err = alc_auto_create_shared_input(codec); |
| 4375 | if (err < 0) |
| 4376 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4377 | err = alc_auto_create_input_ctls(codec); |
| 4378 | if (err < 0) |
| 4379 | return err; |
| 4380 | |
| 4381 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4382 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4383 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4384 | alc_auto_parse_digital(codec); |
| 4385 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4386 | if (!spec->no_analog) |
| 4387 | alc_remove_invalid_adc_nids(codec); |
| 4388 | |
| 4389 | if (ssid_nids) |
| 4390 | alc_ssid_check(codec, ssid_nids); |
| 4391 | |
| 4392 | if (!spec->no_analog) { |
| 4393 | alc_auto_check_switches(codec); |
| 4394 | err = alc_auto_add_mic_boost(codec); |
| 4395 | if (err < 0) |
| 4396 | return err; |
| 4397 | } |
| 4398 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4399 | if (spec->kctls.list) |
| 4400 | add_mixer(spec, spec->kctls.list); |
| 4401 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4402 | if (!spec->no_analog && !spec->cap_mixer) |
| 4403 | set_capture_mixer(codec); |
| 4404 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4405 | return 1; |
| 4406 | } |
| 4407 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 4408 | /* common preparation job for alc_spec */ |
| 4409 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4410 | { |
| 4411 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4412 | int err; |
| 4413 | |
| 4414 | if (!spec) |
| 4415 | return -ENOMEM; |
| 4416 | codec->spec = spec; |
| 4417 | spec->mixer_nid = mixer_nid; |
| 4418 | |
| 4419 | err = alc_codec_rename_from_preset(codec); |
| 4420 | if (err < 0) { |
| 4421 | kfree(spec); |
| 4422 | return err; |
| 4423 | } |
| 4424 | return 0; |
| 4425 | } |
| 4426 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4427 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4428 | { |
| 4429 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4430 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4431 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4432 | } |
| 4433 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4434 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4435 | * ALC880 fix-ups |
| 4436 | */ |
| 4437 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4438 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4439 | ALC880_FIXUP_GPIO2, |
| 4440 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4441 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4442 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4443 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4444 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4445 | ALC880_FIXUP_VOL_KNOB, |
| 4446 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4447 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4448 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4449 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4450 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4451 | ALC880_FIXUP_3ST_BASE, |
| 4452 | ALC880_FIXUP_3ST, |
| 4453 | ALC880_FIXUP_3ST_DIG, |
| 4454 | ALC880_FIXUP_5ST_BASE, |
| 4455 | ALC880_FIXUP_5ST, |
| 4456 | ALC880_FIXUP_5ST_DIG, |
| 4457 | ALC880_FIXUP_6ST_BASE, |
| 4458 | ALC880_FIXUP_6ST, |
| 4459 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4460 | }; |
| 4461 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4462 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4463 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4464 | const struct alc_fixup *fix, int action) |
| 4465 | { |
| 4466 | if (action == ALC_FIXUP_ACT_PROBE) |
| 4467 | snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT); |
| 4468 | } |
| 4469 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4470 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4471 | [ALC880_FIXUP_GPIO1] = { |
| 4472 | .type = ALC_FIXUP_VERBS, |
| 4473 | .v.verbs = alc_gpio1_init_verbs, |
| 4474 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4475 | [ALC880_FIXUP_GPIO2] = { |
| 4476 | .type = ALC_FIXUP_VERBS, |
| 4477 | .v.verbs = alc_gpio2_init_verbs, |
| 4478 | }, |
| 4479 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4480 | .type = ALC_FIXUP_VERBS, |
| 4481 | .v.verbs = (const struct hda_verb[]) { |
| 4482 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4483 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4484 | { } |
| 4485 | }, |
| 4486 | .chained = true, |
| 4487 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4488 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4489 | [ALC880_FIXUP_LG] = { |
| 4490 | .type = ALC_FIXUP_PINS, |
| 4491 | .v.pins = (const struct alc_pincfg[]) { |
| 4492 | /* disable bogus unused pins */ |
| 4493 | { 0x16, 0x411111f0 }, |
| 4494 | { 0x18, 0x411111f0 }, |
| 4495 | { 0x1a, 0x411111f0 }, |
| 4496 | { } |
| 4497 | } |
| 4498 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4499 | [ALC880_FIXUP_W810] = { |
| 4500 | .type = ALC_FIXUP_PINS, |
| 4501 | .v.pins = (const struct alc_pincfg[]) { |
| 4502 | /* disable bogus unused pins */ |
| 4503 | { 0x17, 0x411111f0 }, |
| 4504 | { } |
| 4505 | }, |
| 4506 | .chained = true, |
| 4507 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4508 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4509 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4510 | .type = ALC_FIXUP_VERBS, |
| 4511 | .v.verbs = (const struct hda_verb[]) { |
| 4512 | /* change to EAPD mode */ |
| 4513 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4514 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4515 | {} |
| 4516 | }, |
| 4517 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4518 | [ALC880_FIXUP_TCL_S700] = { |
| 4519 | .type = ALC_FIXUP_VERBS, |
| 4520 | .v.verbs = (const struct hda_verb[]) { |
| 4521 | /* change to EAPD mode */ |
| 4522 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4523 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4524 | {} |
| 4525 | }, |
| 4526 | .chained = true, |
| 4527 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4528 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4529 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4530 | .type = ALC_FIXUP_FUNC, |
| 4531 | .v.func = alc880_fixup_vol_knob, |
| 4532 | }, |
| 4533 | [ALC880_FIXUP_FUJITSU] = { |
| 4534 | /* override all pins as BIOS on old Amilo is broken */ |
| 4535 | .type = ALC_FIXUP_PINS, |
| 4536 | .v.pins = (const struct alc_pincfg[]) { |
| 4537 | { 0x14, 0x0121411f }, /* HP */ |
| 4538 | { 0x15, 0x99030120 }, /* speaker */ |
| 4539 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4540 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4541 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4542 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4543 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4544 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4545 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4546 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4547 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4548 | { } |
| 4549 | }, |
| 4550 | .chained = true, |
| 4551 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4552 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4553 | [ALC880_FIXUP_F1734] = { |
| 4554 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4555 | .type = ALC_FIXUP_PINS, |
| 4556 | .v.pins = (const struct alc_pincfg[]) { |
| 4557 | { 0x14, 0x0121411f }, /* HP */ |
| 4558 | { 0x15, 0x99030120 }, /* speaker */ |
| 4559 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4560 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4561 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4562 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4563 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4564 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4565 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4566 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4567 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4568 | { } |
| 4569 | }, |
| 4570 | .chained = true, |
| 4571 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4572 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4573 | [ALC880_FIXUP_UNIWILL] = { |
| 4574 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4575 | .type = ALC_FIXUP_PINS, |
| 4576 | .v.pins = (const struct alc_pincfg[]) { |
| 4577 | { 0x14, 0x0121411f }, /* HP */ |
| 4578 | { 0x15, 0x99030120 }, /* speaker */ |
| 4579 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4580 | { } |
| 4581 | }, |
| 4582 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4583 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4584 | .type = ALC_FIXUP_PINS, |
| 4585 | .v.pins = (const struct alc_pincfg[]) { |
| 4586 | /* disable bogus unused pins */ |
| 4587 | { 0x17, 0x411111f0 }, |
| 4588 | { 0x19, 0x411111f0 }, |
| 4589 | { 0x1b, 0x411111f0 }, |
| 4590 | { 0x1f, 0x411111f0 }, |
| 4591 | { } |
| 4592 | } |
| 4593 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4594 | [ALC880_FIXUP_Z71V] = { |
| 4595 | .type = ALC_FIXUP_PINS, |
| 4596 | .v.pins = (const struct alc_pincfg[]) { |
| 4597 | /* set up the whole pins as BIOS is utterly broken */ |
| 4598 | { 0x14, 0x99030120 }, /* speaker */ |
| 4599 | { 0x15, 0x0121411f }, /* HP */ |
| 4600 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4601 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4602 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4603 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4604 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4605 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4606 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4607 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4608 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4609 | { } |
| 4610 | } |
| 4611 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4612 | [ALC880_FIXUP_3ST_BASE] = { |
| 4613 | .type = ALC_FIXUP_PINS, |
| 4614 | .v.pins = (const struct alc_pincfg[]) { |
| 4615 | { 0x14, 0x01014010 }, /* line-out */ |
| 4616 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4617 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4618 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4619 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4620 | { 0x19, 0x0121411f }, /* HP */ |
| 4621 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4622 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4623 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4624 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4625 | /* 0x1e is filled in below */ |
| 4626 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4627 | { } |
| 4628 | } |
| 4629 | }, |
| 4630 | [ALC880_FIXUP_3ST] = { |
| 4631 | .type = ALC_FIXUP_PINS, |
| 4632 | .v.pins = (const struct alc_pincfg[]) { |
| 4633 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4634 | { } |
| 4635 | }, |
| 4636 | .chained = true, |
| 4637 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4638 | }, |
| 4639 | [ALC880_FIXUP_3ST_DIG] = { |
| 4640 | .type = ALC_FIXUP_PINS, |
| 4641 | .v.pins = (const struct alc_pincfg[]) { |
| 4642 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4643 | { } |
| 4644 | }, |
| 4645 | .chained = true, |
| 4646 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4647 | }, |
| 4648 | [ALC880_FIXUP_5ST_BASE] = { |
| 4649 | .type = ALC_FIXUP_PINS, |
| 4650 | .v.pins = (const struct alc_pincfg[]) { |
| 4651 | { 0x14, 0x01014010 }, /* front */ |
| 4652 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4653 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4654 | { 0x17, 0x01016412 }, /* surr */ |
| 4655 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4656 | { 0x19, 0x0121411f }, /* HP */ |
| 4657 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4658 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4659 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4660 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4661 | /* 0x1e is filled in below */ |
| 4662 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4663 | { } |
| 4664 | } |
| 4665 | }, |
| 4666 | [ALC880_FIXUP_5ST] = { |
| 4667 | .type = ALC_FIXUP_PINS, |
| 4668 | .v.pins = (const struct alc_pincfg[]) { |
| 4669 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4670 | { } |
| 4671 | }, |
| 4672 | .chained = true, |
| 4673 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4674 | }, |
| 4675 | [ALC880_FIXUP_5ST_DIG] = { |
| 4676 | .type = ALC_FIXUP_PINS, |
| 4677 | .v.pins = (const struct alc_pincfg[]) { |
| 4678 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4679 | { } |
| 4680 | }, |
| 4681 | .chained = true, |
| 4682 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4683 | }, |
| 4684 | [ALC880_FIXUP_6ST_BASE] = { |
| 4685 | .type = ALC_FIXUP_PINS, |
| 4686 | .v.pins = (const struct alc_pincfg[]) { |
| 4687 | { 0x14, 0x01014010 }, /* front */ |
| 4688 | { 0x15, 0x01016412 }, /* surr */ |
| 4689 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4690 | { 0x17, 0x01012414 }, /* side */ |
| 4691 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4692 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4693 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4694 | { 0x1b, 0x0121411f }, /* HP */ |
| 4695 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4696 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4697 | /* 0x1e is filled in below */ |
| 4698 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4699 | { } |
| 4700 | } |
| 4701 | }, |
| 4702 | [ALC880_FIXUP_6ST] = { |
| 4703 | .type = ALC_FIXUP_PINS, |
| 4704 | .v.pins = (const struct alc_pincfg[]) { |
| 4705 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4706 | { } |
| 4707 | }, |
| 4708 | .chained = true, |
| 4709 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4710 | }, |
| 4711 | [ALC880_FIXUP_6ST_DIG] = { |
| 4712 | .type = ALC_FIXUP_PINS, |
| 4713 | .v.pins = (const struct alc_pincfg[]) { |
| 4714 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4715 | { } |
| 4716 | }, |
| 4717 | .chained = true, |
| 4718 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4719 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4720 | }; |
| 4721 | |
| 4722 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4723 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4724 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4725 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4726 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4727 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4728 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4729 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4730 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4731 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4732 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4733 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4734 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4735 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4736 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4737 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4738 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4739 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4740 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4741 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4742 | |
| 4743 | /* Below is the copied entries from alc880_quirks.c. |
| 4744 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4745 | * on these machines, thus they are kept to be compatible with |
| 4746 | * the old static quirks. Once when it's confirmed to work without |
| 4747 | * these overrides, it'd be better to remove. |
| 4748 | */ |
| 4749 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4750 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4751 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4752 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4753 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4754 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4755 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4756 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4757 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4758 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4759 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4760 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4761 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4762 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4763 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4764 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4765 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4766 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4767 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4768 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4769 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4770 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4771 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4772 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4773 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4774 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4775 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4776 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4777 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4778 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4779 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4780 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4781 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4782 | /* default Intel */ |
| 4783 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4784 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4785 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4786 | {} |
| 4787 | }; |
| 4788 | |
| 4789 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4790 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4791 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4792 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4793 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4794 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4795 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4796 | {} |
| 4797 | }; |
| 4798 | |
| 4799 | |
| 4800 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4801 | * OK, here we have finally the patch for ALC880 |
| 4802 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4803 | static int patch_alc880(struct hda_codec *codec) |
| 4804 | { |
| 4805 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4806 | int err; |
| 4807 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 4808 | err = alc_alloc_spec(codec, 0x0b); |
| 4809 | if (err < 0) |
| 4810 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4811 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 4812 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4813 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4814 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4815 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4816 | alc880_fixups); |
| 4817 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4818 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4819 | /* automatic parse from the BIOS config */ |
| 4820 | err = alc880_parse_auto_config(codec); |
| 4821 | if (err < 0) |
| 4822 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4823 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4824 | if (!spec->no_analog) { |
| 4825 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4826 | if (err < 0) |
| 4827 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4828 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4829 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4830 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4831 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4832 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4833 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4834 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4835 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4836 | |
| 4837 | error: |
| 4838 | alc_free(codec); |
| 4839 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4840 | } |
| 4841 | |
| 4842 | |
| 4843 | /* |
| 4844 | * ALC260 support |
| 4845 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4846 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4847 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4848 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4849 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4850 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4851 | } |
| 4852 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4853 | /* |
| 4854 | * Pin config fixes |
| 4855 | */ |
| 4856 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4857 | ALC260_FIXUP_HP_DC5750, |
| 4858 | ALC260_FIXUP_HP_PIN_0F, |
| 4859 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4860 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4861 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4862 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4863 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4864 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4865 | }; |
| 4866 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4867 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4868 | { |
| 4869 | struct alc_spec *spec = codec->spec; |
| 4870 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4871 | spec->hp_jack_present); |
| 4872 | } |
| 4873 | |
| 4874 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4875 | const struct alc_fixup *fix, int action) |
| 4876 | { |
| 4877 | struct alc_spec *spec = codec->spec; |
| 4878 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4879 | /* although the machine has only one output pin, we need to |
| 4880 | * toggle GPIO1 according to the jack state |
| 4881 | */ |
| 4882 | spec->automute_hook = alc260_gpio1_automute; |
| 4883 | spec->detect_hp = 1; |
| 4884 | spec->automute_speaker = 1; |
| 4885 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
| 4886 | snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); |
| 4887 | spec->unsol_event = alc_sku_unsol_event; |
| 4888 | add_verb(codec->spec, alc_gpio1_init_verbs); |
| 4889 | } |
| 4890 | } |
| 4891 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4892 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 4893 | const struct alc_fixup *fix, int action) |
| 4894 | { |
| 4895 | struct alc_spec *spec = codec->spec; |
| 4896 | static const struct alc_pincfg pincfgs[] = { |
| 4897 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 4898 | { 0x12, 0x90a60160 }, /* int mic */ |
| 4899 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 4900 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 4901 | /* disable bogus I/O pins */ |
| 4902 | { 0x10, 0x411111f0 }, |
| 4903 | { 0x11, 0x411111f0 }, |
| 4904 | { 0x14, 0x411111f0 }, |
| 4905 | { 0x15, 0x411111f0 }, |
| 4906 | { 0x16, 0x411111f0 }, |
| 4907 | { 0x17, 0x411111f0 }, |
| 4908 | { 0x19, 0x411111f0 }, |
| 4909 | { } |
| 4910 | }; |
| 4911 | |
| 4912 | switch (action) { |
| 4913 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 4914 | alc_apply_pincfgs(codec, pincfgs); |
| 4915 | break; |
| 4916 | case ALC_FIXUP_ACT_PROBE: |
| 4917 | spec->init_amp = ALC_INIT_NONE; |
| 4918 | break; |
| 4919 | } |
| 4920 | } |
| 4921 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4922 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4923 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4924 | .type = ALC_FIXUP_PINS, |
| 4925 | .v.pins = (const struct alc_pincfg[]) { |
| 4926 | { 0x11, 0x90130110 }, /* speaker */ |
| 4927 | { } |
| 4928 | } |
| 4929 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4930 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 4931 | .type = ALC_FIXUP_PINS, |
| 4932 | .v.pins = (const struct alc_pincfg[]) { |
| 4933 | { 0x0f, 0x01214000 }, /* HP */ |
| 4934 | { } |
| 4935 | } |
| 4936 | }, |
| 4937 | [ALC260_FIXUP_COEF] = { |
| 4938 | .type = ALC_FIXUP_VERBS, |
| 4939 | .v.verbs = (const struct hda_verb[]) { |
| 4940 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4941 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 4942 | { } |
| 4943 | }, |
| 4944 | .chained = true, |
| 4945 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4946 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4947 | [ALC260_FIXUP_GPIO1] = { |
| 4948 | .type = ALC_FIXUP_VERBS, |
| 4949 | .v.verbs = alc_gpio1_init_verbs, |
| 4950 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4951 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 4952 | .type = ALC_FIXUP_FUNC, |
| 4953 | .v.func = alc260_fixup_gpio1_toggle, |
| 4954 | .chained = true, |
| 4955 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4956 | }, |
| 4957 | [ALC260_FIXUP_REPLACER] = { |
| 4958 | .type = ALC_FIXUP_VERBS, |
| 4959 | .v.verbs = (const struct hda_verb[]) { |
| 4960 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4961 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4962 | { } |
| 4963 | }, |
| 4964 | .chained = true, |
| 4965 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 4966 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4967 | [ALC260_FIXUP_HP_B1900] = { |
| 4968 | .type = ALC_FIXUP_FUNC, |
| 4969 | .v.func = alc260_fixup_gpio1_toggle, |
| 4970 | .chained = true, |
| 4971 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4972 | }, |
| 4973 | [ALC260_FIXUP_KN1] = { |
| 4974 | .type = ALC_FIXUP_FUNC, |
| 4975 | .v.func = alc260_fixup_kn1, |
| 4976 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4977 | }; |
| 4978 | |
| 4979 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4980 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4981 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4982 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4983 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4984 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 4985 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4986 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4987 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4988 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4989 | {} |
| 4990 | }; |
| 4991 | |
| 4992 | /* |
| 4993 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4994 | static int patch_alc260(struct hda_codec *codec) |
| 4995 | { |
| 4996 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4997 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4998 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 4999 | err = alc_alloc_spec(codec, 0x07); |
| 5000 | if (err < 0) |
| 5001 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5002 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 5003 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5004 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5005 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5006 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5007 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5008 | /* automatic parse from the BIOS config */ |
| 5009 | err = alc260_parse_auto_config(codec); |
| 5010 | if (err < 0) |
| 5011 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5012 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5013 | if (!spec->no_analog) { |
| 5014 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5015 | if (err < 0) |
| 5016 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5017 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5018 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5019 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5020 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5021 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5022 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5023 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5024 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5025 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5026 | |
| 5027 | error: |
| 5028 | alc_free(codec); |
| 5029 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5030 | } |
| 5031 | |
| 5032 | |
| 5033 | /* |
| 5034 | * ALC882/883/885/888/889 support |
| 5035 | * |
| 5036 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5037 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5038 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5039 | * 6-channel independent captures. |
| 5040 | * |
| 5041 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5042 | * driver yet). |
| 5043 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5044 | |
| 5045 | /* |
| 5046 | * Pin config fixes |
| 5047 | */ |
| 5048 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5049 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5050 | ALC882_FIXUP_LENOVO_Y530, |
| 5051 | ALC882_FIXUP_PB_M5210, |
| 5052 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5053 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5054 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5055 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5056 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5057 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5058 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5059 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5060 | ALC882_FIXUP_GPIO1, |
| 5061 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5062 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5063 | ALC889_FIXUP_COEF, |
| 5064 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5065 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5066 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5067 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5068 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5069 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5070 | ALC889_FIXUP_MBP_VREF, |
| 5071 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5072 | }; |
| 5073 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5074 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5075 | const struct alc_fixup *fix, int action) |
| 5076 | { |
| 5077 | if (action != ALC_FIXUP_ACT_INIT) |
| 5078 | return; |
| 5079 | alc889_coef_init(codec); |
| 5080 | } |
| 5081 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5082 | /* toggle speaker-output according to the hp-jack state */ |
| 5083 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5084 | { |
| 5085 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5086 | |
| 5087 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5088 | AC_VERB_GET_GPIO_DATA, 0); |
| 5089 | |
| 5090 | if (!muted) |
| 5091 | gpiostate |= (1 << pin); |
| 5092 | else |
| 5093 | gpiostate &= ~(1 << pin); |
| 5094 | |
| 5095 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5096 | AC_VERB_GET_GPIO_MASK, 0); |
| 5097 | gpiomask |= (1 << pin); |
| 5098 | |
| 5099 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5100 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5101 | gpiodir |= (1 << pin); |
| 5102 | |
| 5103 | |
| 5104 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5105 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5106 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5107 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5108 | |
| 5109 | msleep(1); |
| 5110 | |
| 5111 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5112 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5113 | } |
| 5114 | |
| 5115 | /* set up GPIO at initialization */ |
| 5116 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5117 | const struct alc_fixup *fix, int action) |
| 5118 | { |
| 5119 | if (action != ALC_FIXUP_ACT_INIT) |
| 5120 | return; |
| 5121 | alc882_gpio_mute(codec, 0, 0); |
| 5122 | alc882_gpio_mute(codec, 1, 0); |
| 5123 | } |
| 5124 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5125 | /* Fix the connection of some pins for ALC889: |
| 5126 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5127 | * work correctly (bko#42740) |
| 5128 | */ |
| 5129 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5130 | const struct alc_fixup *fix, int action) |
| 5131 | { |
| 5132 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5133 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5134 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5135 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5136 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5137 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5138 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5139 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5140 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5141 | /* restore the connections */ |
| 5142 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5143 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5144 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5145 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5146 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5147 | } |
| 5148 | } |
| 5149 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5150 | /* Set VREF on HP pin */ |
| 5151 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5152 | const struct alc_fixup *fix, int action) |
| 5153 | { |
| 5154 | struct alc_spec *spec = codec->spec; |
| 5155 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5156 | int i; |
| 5157 | |
| 5158 | if (action != ALC_FIXUP_ACT_INIT) |
| 5159 | return; |
| 5160 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5161 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5162 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5163 | continue; |
| 5164 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5165 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5166 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5167 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5168 | spec->keep_vref_in_automute = 1; |
| 5169 | break; |
| 5170 | } |
| 5171 | } |
| 5172 | |
| 5173 | /* Set VREF on speaker pins on imac91 */ |
| 5174 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5175 | const struct alc_fixup *fix, int action) |
| 5176 | { |
| 5177 | struct alc_spec *spec = codec->spec; |
| 5178 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5179 | int i; |
| 5180 | |
| 5181 | if (action != ALC_FIXUP_ACT_INIT) |
| 5182 | return; |
| 5183 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5184 | unsigned int val; |
| 5185 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5186 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5187 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5188 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5189 | } |
| 5190 | spec->keep_vref_in_automute = 1; |
| 5191 | } |
| 5192 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5193 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5194 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5195 | .type = ALC_FIXUP_PINS, |
| 5196 | .v.pins = (const struct alc_pincfg[]) { |
| 5197 | { 0x15, 0x01080104 }, /* side */ |
| 5198 | { 0x16, 0x01011012 }, /* rear */ |
| 5199 | { 0x17, 0x01016011 }, /* clfe */ |
| 5200 | { } |
| 5201 | } |
| 5202 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5203 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5204 | .type = ALC_FIXUP_PINS, |
| 5205 | .v.pins = (const struct alc_pincfg[]) { |
| 5206 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5207 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5208 | { } |
| 5209 | } |
| 5210 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5211 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5212 | .type = ALC_FIXUP_VERBS, |
| 5213 | .v.verbs = (const struct hda_verb[]) { |
| 5214 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5215 | {} |
| 5216 | } |
| 5217 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5218 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5219 | .type = ALC_FIXUP_SKU, |
| 5220 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 5221 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5222 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5223 | .type = ALC_FIXUP_PINS, |
| 5224 | .v.pins = (const struct alc_pincfg[]) { |
| 5225 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5226 | { } |
| 5227 | } |
| 5228 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5229 | [ALC889_FIXUP_CD] = { |
| 5230 | .type = ALC_FIXUP_PINS, |
| 5231 | .v.pins = (const struct alc_pincfg[]) { |
| 5232 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5233 | { } |
| 5234 | } |
| 5235 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5236 | [ALC889_FIXUP_VAIO_TT] = { |
| 5237 | .type = ALC_FIXUP_PINS, |
| 5238 | .v.pins = (const struct alc_pincfg[]) { |
| 5239 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5240 | { } |
| 5241 | } |
| 5242 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5243 | [ALC888_FIXUP_EEE1601] = { |
| 5244 | .type = ALC_FIXUP_VERBS, |
| 5245 | .v.verbs = (const struct hda_verb[]) { |
| 5246 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5247 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5248 | { } |
| 5249 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5250 | }, |
| 5251 | [ALC882_FIXUP_EAPD] = { |
| 5252 | .type = ALC_FIXUP_VERBS, |
| 5253 | .v.verbs = (const struct hda_verb[]) { |
| 5254 | /* change to EAPD mode */ |
| 5255 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5256 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5257 | { } |
| 5258 | } |
| 5259 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5260 | [ALC883_FIXUP_EAPD] = { |
| 5261 | .type = ALC_FIXUP_VERBS, |
| 5262 | .v.verbs = (const struct hda_verb[]) { |
| 5263 | /* change to EAPD mode */ |
| 5264 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5265 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5266 | { } |
| 5267 | } |
| 5268 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5269 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5270 | .type = ALC_FIXUP_VERBS, |
| 5271 | .v.verbs = (const struct hda_verb[]) { |
| 5272 | /* eanable EAPD on Acer laptops */ |
| 5273 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5274 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5275 | { } |
| 5276 | } |
| 5277 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5278 | [ALC882_FIXUP_GPIO1] = { |
| 5279 | .type = ALC_FIXUP_VERBS, |
| 5280 | .v.verbs = alc_gpio1_init_verbs, |
| 5281 | }, |
| 5282 | [ALC882_FIXUP_GPIO2] = { |
| 5283 | .type = ALC_FIXUP_VERBS, |
| 5284 | .v.verbs = alc_gpio2_init_verbs, |
| 5285 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5286 | [ALC882_FIXUP_GPIO3] = { |
| 5287 | .type = ALC_FIXUP_VERBS, |
| 5288 | .v.verbs = alc_gpio3_init_verbs, |
| 5289 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5290 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5291 | .type = ALC_FIXUP_VERBS, |
| 5292 | .v.verbs = alc_gpio1_init_verbs, |
| 5293 | .chained = true, |
| 5294 | .chain_id = ALC882_FIXUP_EAPD, |
| 5295 | }, |
| 5296 | [ALC889_FIXUP_COEF] = { |
| 5297 | .type = ALC_FIXUP_FUNC, |
| 5298 | .v.func = alc889_fixup_coef, |
| 5299 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5300 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5301 | .type = ALC_FIXUP_PINS, |
| 5302 | .v.pins = (const struct alc_pincfg[]) { |
| 5303 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5304 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5305 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5306 | }, |
| 5307 | .chained = true, |
| 5308 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5309 | }, |
| 5310 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5311 | .type = ALC_FIXUP_PINS, |
| 5312 | .v.pins = (const struct alc_pincfg[]) { |
| 5313 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5314 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5315 | { } |
| 5316 | }, |
| 5317 | .chained = true, |
| 5318 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5319 | }, |
| 5320 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5321 | /* additional init verbs for Acer Aspire 8930G */ |
| 5322 | .type = ALC_FIXUP_VERBS, |
| 5323 | .v.verbs = (const struct hda_verb[]) { |
| 5324 | /* Enable all DACs */ |
| 5325 | /* DAC DISABLE/MUTE 1? */ |
| 5326 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5327 | * apparently. Init=0x38 */ |
| 5328 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5329 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5330 | /* DAC DISABLE/MUTE 2? */ |
| 5331 | /* some bit here disables the other DACs. |
| 5332 | * Init=0x4900 */ |
| 5333 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5334 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5335 | /* DMIC fix |
| 5336 | * This laptop has a stereo digital microphone. |
| 5337 | * The mics are only 1cm apart which makes the stereo |
| 5338 | * useless. However, either the mic or the ALC889 |
| 5339 | * makes the signal become a difference/sum signal |
| 5340 | * instead of standard stereo, which is annoying. |
| 5341 | * So instead we flip this bit which makes the |
| 5342 | * codec replicate the sum signal to both channels, |
| 5343 | * turning it into a normal mono mic. |
| 5344 | */ |
| 5345 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5346 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5347 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5348 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5349 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5350 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5351 | }, |
| 5352 | .chained = true, |
| 5353 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5354 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5355 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5356 | .type = ALC_FIXUP_FUNC, |
| 5357 | .v.func = alc885_fixup_macpro_gpio, |
| 5358 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5359 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5360 | .type = ALC_FIXUP_FUNC, |
| 5361 | .v.func = alc889_fixup_dac_route, |
| 5362 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5363 | [ALC889_FIXUP_MBP_VREF] = { |
| 5364 | .type = ALC_FIXUP_FUNC, |
| 5365 | .v.func = alc889_fixup_mbp_vref, |
| 5366 | .chained = true, |
| 5367 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5368 | }, |
| 5369 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5370 | .type = ALC_FIXUP_FUNC, |
| 5371 | .v.func = alc889_fixup_imac91_vref, |
| 5372 | .chained = true, |
| 5373 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5374 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5375 | }; |
| 5376 | |
| 5377 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5378 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5379 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5380 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5381 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5382 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5383 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5384 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5385 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5386 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5387 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5388 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5389 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5390 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5391 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5392 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5393 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5394 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5395 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5396 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5397 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5398 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5399 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5400 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5401 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5402 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5403 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5404 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5405 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5406 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5407 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5408 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5409 | |
| 5410 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5411 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5412 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5413 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5414 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5415 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5416 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5417 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5418 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5419 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5420 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5421 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5422 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5423 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5424 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5425 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5426 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5427 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5428 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5429 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5430 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5431 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5432 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5433 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5434 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5435 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5436 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5437 | 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] | 5438 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5439 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5440 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5441 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5442 | {} |
| 5443 | }; |
| 5444 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5445 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5446 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5447 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5448 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
| 5449 | {} |
| 5450 | }; |
| 5451 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5452 | /* |
| 5453 | * BIOS auto configuration |
| 5454 | */ |
| 5455 | /* almost identical with ALC880 parser... */ |
| 5456 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5457 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5458 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5459 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5460 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5461 | } |
| 5462 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5463 | /* |
| 5464 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5465 | static int patch_alc882(struct hda_codec *codec) |
| 5466 | { |
| 5467 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5468 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5469 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 5470 | err = alc_alloc_spec(codec, 0x0b); |
| 5471 | if (err < 0) |
| 5472 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5473 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 5474 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5475 | |
| 5476 | switch (codec->vendor_id) { |
| 5477 | case 0x10ec0882: |
| 5478 | case 0x10ec0885: |
| 5479 | break; |
| 5480 | default: |
| 5481 | /* ALC883 and variants */ |
| 5482 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5483 | break; |
| 5484 | } |
| 5485 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5486 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5487 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5488 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5489 | |
| 5490 | alc_auto_parse_customize_define(codec); |
| 5491 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5492 | /* automatic parse from the BIOS config */ |
| 5493 | err = alc882_parse_auto_config(codec); |
| 5494 | if (err < 0) |
| 5495 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5496 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5497 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5498 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5499 | if (err < 0) |
| 5500 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5501 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5502 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5503 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5504 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5505 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5506 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5507 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5508 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5509 | |
| 5510 | error: |
| 5511 | alc_free(codec); |
| 5512 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5513 | } |
| 5514 | |
| 5515 | |
| 5516 | /* |
| 5517 | * ALC262 support |
| 5518 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5519 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5520 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5521 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5522 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5523 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5524 | } |
| 5525 | |
| 5526 | /* |
| 5527 | * Pin config fixes |
| 5528 | */ |
| 5529 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5530 | ALC262_FIXUP_FSC_H270, |
| 5531 | ALC262_FIXUP_HP_Z200, |
| 5532 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5533 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5534 | ALC262_FIXUP_BENQ, |
| 5535 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5536 | }; |
| 5537 | |
| 5538 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5539 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5540 | .type = ALC_FIXUP_PINS, |
| 5541 | .v.pins = (const struct alc_pincfg[]) { |
| 5542 | { 0x14, 0x99130110 }, /* speaker */ |
| 5543 | { 0x15, 0x0221142f }, /* front HP */ |
| 5544 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5545 | { } |
| 5546 | } |
| 5547 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5548 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5549 | .type = ALC_FIXUP_PINS, |
| 5550 | .v.pins = (const struct alc_pincfg[]) { |
| 5551 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5552 | { } |
| 5553 | } |
| 5554 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5555 | [ALC262_FIXUP_TYAN] = { |
| 5556 | .type = ALC_FIXUP_PINS, |
| 5557 | .v.pins = (const struct alc_pincfg[]) { |
| 5558 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5559 | { } |
| 5560 | } |
| 5561 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5562 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5563 | .type = ALC_FIXUP_VERBS, |
| 5564 | .v.verbs = (const struct hda_verb[]) { |
| 5565 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5566 | {} |
| 5567 | }, |
| 5568 | .chained = true, |
| 5569 | .chain_id = ALC262_FIXUP_BENQ, |
| 5570 | }, |
| 5571 | [ALC262_FIXUP_BENQ] = { |
| 5572 | .type = ALC_FIXUP_VERBS, |
| 5573 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5574 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5575 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5576 | {} |
| 5577 | } |
| 5578 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5579 | [ALC262_FIXUP_BENQ_T31] = { |
| 5580 | .type = ALC_FIXUP_VERBS, |
| 5581 | .v.verbs = (const struct hda_verb[]) { |
| 5582 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5583 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5584 | {} |
| 5585 | } |
| 5586 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5587 | }; |
| 5588 | |
| 5589 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5590 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5591 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5592 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5593 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5594 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5595 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5596 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5597 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5598 | {} |
| 5599 | }; |
| 5600 | |
| 5601 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5602 | /* |
| 5603 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5604 | static int patch_alc262(struct hda_codec *codec) |
| 5605 | { |
| 5606 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5607 | int err; |
| 5608 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 5609 | err = alc_alloc_spec(codec, 0x0b); |
| 5610 | if (err < 0) |
| 5611 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5612 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 5613 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5614 | |
| 5615 | #if 0 |
| 5616 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5617 | * under-run |
| 5618 | */ |
| 5619 | { |
| 5620 | int tmp; |
| 5621 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5622 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5623 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5624 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5625 | } |
| 5626 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5627 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5628 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5629 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 5630 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5631 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5632 | alc_auto_parse_customize_define(codec); |
| 5633 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5634 | /* automatic parse from the BIOS config */ |
| 5635 | err = alc262_parse_auto_config(codec); |
| 5636 | if (err < 0) |
| 5637 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5638 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5639 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5640 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5641 | if (err < 0) |
| 5642 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5643 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5644 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5645 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5646 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5647 | spec->shutup = alc_eapd_shutup; |
| 5648 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5649 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5650 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5651 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5652 | |
| 5653 | error: |
| 5654 | alc_free(codec); |
| 5655 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5656 | } |
| 5657 | |
| 5658 | /* |
| 5659 | * ALC268 |
| 5660 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5661 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5662 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5663 | .ops = &snd_hda_bind_sw, |
| 5664 | .values = { |
| 5665 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5666 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5667 | 0 |
| 5668 | }, |
| 5669 | }; |
| 5670 | |
| 5671 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5672 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5673 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5674 | { } |
| 5675 | }; |
| 5676 | |
| 5677 | /* set PCBEEP vol = 0, mute connections */ |
| 5678 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5679 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5680 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5681 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5682 | { } |
| 5683 | }; |
| 5684 | |
| 5685 | /* |
| 5686 | * BIOS auto configuration |
| 5687 | */ |
| 5688 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5689 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5690 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5691 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5692 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5693 | if (err > 0) { |
| 5694 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5695 | add_mixer(spec, alc268_beep_mixer); |
| 5696 | add_verb(spec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5697 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5698 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5699 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5700 | } |
| 5701 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5702 | /* |
| 5703 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5704 | static int patch_alc268(struct hda_codec *codec) |
| 5705 | { |
| 5706 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5707 | int i, has_beep, err; |
| 5708 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5709 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 5710 | err = alc_alloc_spec(codec, 0); |
| 5711 | if (err < 0) |
| 5712 | return err; |
| 5713 | |
| 5714 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5715 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5716 | /* automatic parse from the BIOS config */ |
| 5717 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5718 | if (err < 0) |
| 5719 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5720 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5721 | has_beep = 0; |
| 5722 | for (i = 0; i < spec->num_mixers; i++) { |
| 5723 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5724 | has_beep = 1; |
| 5725 | break; |
| 5726 | } |
| 5727 | } |
| 5728 | |
| 5729 | if (has_beep) { |
| 5730 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5731 | if (err < 0) |
| 5732 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5733 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5734 | /* override the amp caps for beep generator */ |
| 5735 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5736 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5737 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5738 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5739 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5740 | } |
| 5741 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5742 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5743 | spec->shutup = alc_eapd_shutup; |
| 5744 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5745 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5746 | |
| 5747 | error: |
| 5748 | alc_free(codec); |
| 5749 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5750 | } |
| 5751 | |
| 5752 | /* |
| 5753 | * ALC269 |
| 5754 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5755 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5756 | .substreams = 1, |
| 5757 | .channels_min = 2, |
| 5758 | .channels_max = 8, |
| 5759 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5760 | /* NID is set in alc_build_pcms */ |
| 5761 | .ops = { |
| 5762 | .open = alc_playback_pcm_open, |
| 5763 | .prepare = alc_playback_pcm_prepare, |
| 5764 | .cleanup = alc_playback_pcm_cleanup |
| 5765 | }, |
| 5766 | }; |
| 5767 | |
| 5768 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5769 | .substreams = 1, |
| 5770 | .channels_min = 2, |
| 5771 | .channels_max = 2, |
| 5772 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5773 | /* NID is set in alc_build_pcms */ |
| 5774 | }; |
| 5775 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5776 | /* different alc269-variants */ |
| 5777 | enum { |
| 5778 | ALC269_TYPE_ALC269VA, |
| 5779 | ALC269_TYPE_ALC269VB, |
| 5780 | ALC269_TYPE_ALC269VC, |
| 5781 | }; |
| 5782 | |
| 5783 | /* |
| 5784 | * BIOS auto configuration |
| 5785 | */ |
| 5786 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5787 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5788 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5789 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5790 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5791 | struct alc_spec *spec = codec->spec; |
| 5792 | const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? |
| 5793 | alc269va_ssids : alc269_ssids; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5794 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5795 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5796 | } |
| 5797 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5798 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 5799 | { |
| 5800 | int val = alc_read_coef_idx(codec, 0x04); |
| 5801 | if (power_up) |
| 5802 | val |= 1 << 11; |
| 5803 | else |
| 5804 | val &= ~(1 << 11); |
| 5805 | alc_write_coef_idx(codec, 0x04, val); |
| 5806 | } |
| 5807 | |
| 5808 | static void alc269_shutup(struct hda_codec *codec) |
| 5809 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5810 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5811 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5812 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5813 | alc269_toggle_power_output(codec, 0); |
| 5814 | msleep(150); |
| 5815 | } |
| 5816 | } |
| 5817 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5818 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5819 | static int alc269_resume(struct hda_codec *codec) |
| 5820 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5821 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5822 | alc269_toggle_power_output(codec, 0); |
| 5823 | msleep(150); |
| 5824 | } |
| 5825 | |
| 5826 | codec->patch_ops.init(codec); |
| 5827 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5828 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5829 | alc269_toggle_power_output(codec, 1); |
| 5830 | msleep(200); |
| 5831 | } |
| 5832 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5833 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5834 | alc269_toggle_power_output(codec, 1); |
| 5835 | |
| 5836 | snd_hda_codec_resume_amp(codec); |
| 5837 | snd_hda_codec_resume_cache(codec); |
| 5838 | hda_call_check_power_status(codec, 0x01); |
| 5839 | return 0; |
| 5840 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5841 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5842 | |
| 5843 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5844 | const struct alc_fixup *fix, int action) |
| 5845 | { |
| 5846 | int coef; |
| 5847 | |
| 5848 | if (action != ALC_FIXUP_ACT_INIT) |
| 5849 | return; |
| 5850 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5851 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5852 | } |
| 5853 | |
| 5854 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5855 | const struct alc_fixup *fix, int action) |
| 5856 | { |
| 5857 | static const struct hda_verb verbs[] = { |
| 5858 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5859 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5860 | {} |
| 5861 | }; |
| 5862 | unsigned int cfg; |
| 5863 | |
| 5864 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5865 | return; |
| 5866 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5867 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5868 | snd_hda_sequence_write(codec, verbs); |
| 5869 | } |
| 5870 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5871 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5872 | const struct alc_fixup *fix, int action) |
| 5873 | { |
| 5874 | struct alc_spec *spec = codec->spec; |
| 5875 | |
| 5876 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5877 | return; |
| 5878 | |
| 5879 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5880 | * fix the sample rate of analog I/O to 44.1kHz |
| 5881 | */ |
| 5882 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5883 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5884 | } |
| 5885 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5886 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 5887 | const struct alc_fixup *fix, int action) |
| 5888 | { |
| 5889 | int coef; |
| 5890 | |
| 5891 | if (action != ALC_FIXUP_ACT_INIT) |
| 5892 | return; |
| 5893 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5894 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 5895 | * Below is a workaround specific to ALC269 to control the dmic |
| 5896 | * signal source as mono. |
| 5897 | */ |
| 5898 | coef = alc_read_coef_idx(codec, 0x07); |
| 5899 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 5900 | } |
| 5901 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5902 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 5903 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 5904 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5905 | |
| 5906 | snd_hda_codec_write(codec, 0x20, 0, |
| 5907 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5908 | snd_hda_codec_write(codec, 0x20, 0, |
| 5909 | AC_VERB_SET_PROC_COEF, 0x680); |
| 5910 | |
| 5911 | snd_hda_codec_write(codec, 0x20, 0, |
| 5912 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5913 | snd_hda_codec_write(codec, 0x20, 0, |
| 5914 | AC_VERB_SET_PROC_COEF, 0x480); |
| 5915 | } |
| 5916 | |
| 5917 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 5918 | const struct alc_fixup *fix, int action) |
| 5919 | { |
| 5920 | struct alc_spec *spec = codec->spec; |
| 5921 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5922 | return; |
| 5923 | spec->automute_hook = alc269_quanta_automute; |
| 5924 | } |
| 5925 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5926 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 5927 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 5928 | { |
| 5929 | struct hda_codec *codec = private_data; |
| 5930 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5931 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5932 | } |
| 5933 | |
| 5934 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 5935 | const struct alc_fixup *fix, int action) |
| 5936 | { |
| 5937 | struct alc_spec *spec = codec->spec; |
| 5938 | switch (action) { |
| 5939 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5940 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 5941 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5942 | /* fallthru */ |
| 5943 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5944 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5945 | break; |
| 5946 | } |
| 5947 | } |
| 5948 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5949 | enum { |
| 5950 | ALC269_FIXUP_SONY_VAIO, |
| 5951 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 5952 | ALC269_FIXUP_DELL_M101Z, |
| 5953 | ALC269_FIXUP_SKU_IGNORE, |
| 5954 | ALC269_FIXUP_ASUS_G73JW, |
| 5955 | ALC269_FIXUP_LENOVO_EAPD, |
| 5956 | ALC275_FIXUP_SONY_HWEQ, |
| 5957 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5958 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5959 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5960 | ALC269_FIXUP_QUANTA_MUTE, |
| 5961 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5962 | ALC269_FIXUP_AMIC, |
| 5963 | ALC269_FIXUP_DMIC, |
| 5964 | ALC269VB_FIXUP_AMIC, |
| 5965 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5966 | ALC269_FIXUP_MIC2_MUTE_LED, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5967 | }; |
| 5968 | |
| 5969 | static const struct alc_fixup alc269_fixups[] = { |
| 5970 | [ALC269_FIXUP_SONY_VAIO] = { |
| 5971 | .type = ALC_FIXUP_VERBS, |
| 5972 | .v.verbs = (const struct hda_verb[]) { |
| 5973 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 5974 | {} |
| 5975 | } |
| 5976 | }, |
| 5977 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 5978 | .type = ALC_FIXUP_VERBS, |
| 5979 | .v.verbs = (const struct hda_verb[]) { |
| 5980 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 5981 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 5982 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 5983 | { } |
| 5984 | }, |
| 5985 | .chained = true, |
| 5986 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 5987 | }, |
| 5988 | [ALC269_FIXUP_DELL_M101Z] = { |
| 5989 | .type = ALC_FIXUP_VERBS, |
| 5990 | .v.verbs = (const struct hda_verb[]) { |
| 5991 | /* Enables internal speaker */ |
| 5992 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 5993 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 5994 | {} |
| 5995 | } |
| 5996 | }, |
| 5997 | [ALC269_FIXUP_SKU_IGNORE] = { |
| 5998 | .type = ALC_FIXUP_SKU, |
| 5999 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 6000 | }, |
| 6001 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6002 | .type = ALC_FIXUP_PINS, |
| 6003 | .v.pins = (const struct alc_pincfg[]) { |
| 6004 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6005 | { } |
| 6006 | } |
| 6007 | }, |
| 6008 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6009 | .type = ALC_FIXUP_VERBS, |
| 6010 | .v.verbs = (const struct hda_verb[]) { |
| 6011 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6012 | {} |
| 6013 | } |
| 6014 | }, |
| 6015 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6016 | .type = ALC_FIXUP_FUNC, |
| 6017 | .v.func = alc269_fixup_hweq, |
| 6018 | .chained = true, |
| 6019 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6020 | }, |
| 6021 | [ALC271_FIXUP_DMIC] = { |
| 6022 | .type = ALC_FIXUP_FUNC, |
| 6023 | .v.func = alc271_fixup_dmic, |
| 6024 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6025 | [ALC269_FIXUP_PCM_44K] = { |
| 6026 | .type = ALC_FIXUP_FUNC, |
| 6027 | .v.func = alc269_fixup_pcm_44k, |
| 6028 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6029 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6030 | .type = ALC_FIXUP_FUNC, |
| 6031 | .v.func = alc269_fixup_stereo_dmic, |
| 6032 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6033 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6034 | .type = ALC_FIXUP_FUNC, |
| 6035 | .v.func = alc269_fixup_quanta_mute, |
| 6036 | }, |
| 6037 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6038 | .type = ALC_FIXUP_PINS, |
| 6039 | .v.pins = (const struct alc_pincfg[]) { |
| 6040 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6041 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6042 | { } |
| 6043 | }, |
| 6044 | .chained = true, |
| 6045 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6046 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6047 | [ALC269_FIXUP_AMIC] = { |
| 6048 | .type = ALC_FIXUP_PINS, |
| 6049 | .v.pins = (const struct alc_pincfg[]) { |
| 6050 | { 0x14, 0x99130110 }, /* speaker */ |
| 6051 | { 0x15, 0x0121401f }, /* HP out */ |
| 6052 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6053 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6054 | { } |
| 6055 | }, |
| 6056 | }, |
| 6057 | [ALC269_FIXUP_DMIC] = { |
| 6058 | .type = ALC_FIXUP_PINS, |
| 6059 | .v.pins = (const struct alc_pincfg[]) { |
| 6060 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6061 | { 0x14, 0x99130110 }, /* speaker */ |
| 6062 | { 0x15, 0x0121401f }, /* HP out */ |
| 6063 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6064 | { } |
| 6065 | }, |
| 6066 | }, |
| 6067 | [ALC269VB_FIXUP_AMIC] = { |
| 6068 | .type = ALC_FIXUP_PINS, |
| 6069 | .v.pins = (const struct alc_pincfg[]) { |
| 6070 | { 0x14, 0x99130110 }, /* speaker */ |
| 6071 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6072 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6073 | { 0x21, 0x0121401f }, /* HP out */ |
| 6074 | { } |
| 6075 | }, |
| 6076 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6077 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6078 | .type = ALC_FIXUP_PINS, |
| 6079 | .v.pins = (const struct alc_pincfg[]) { |
| 6080 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6081 | { 0x14, 0x99130110 }, /* speaker */ |
| 6082 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6083 | { 0x21, 0x0121401f }, /* HP out */ |
| 6084 | { } |
| 6085 | }, |
| 6086 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6087 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6088 | .type = ALC_FIXUP_FUNC, |
| 6089 | .v.func = alc269_fixup_mic2_mute, |
| 6090 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6091 | }; |
| 6092 | |
| 6093 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6094 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 5ac5755 | 2012-04-20 10:01:46 +0200 | [diff] [blame] | 6095 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6096 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6097 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6098 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6099 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6100 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6101 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6102 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6103 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6104 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6105 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6106 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 6107 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6108 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6109 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6110 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6111 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6112 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6113 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6114 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6115 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6116 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6117 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6118 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6119 | /* Below is a quirk table taken from the old code. |
| 6120 | * Basically the device should work as is without the fixup table. |
| 6121 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6122 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6123 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6124 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6125 | ALC269_FIXUP_AMIC), |
| 6126 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6127 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6128 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6129 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6130 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6131 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6132 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6133 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6134 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6135 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6136 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6137 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6138 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6139 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6140 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6141 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6142 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6143 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6144 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6145 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6146 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6147 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6148 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6149 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6150 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6151 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6152 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6153 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6154 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6155 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6156 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6157 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6158 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6159 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6160 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6161 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6162 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6163 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6164 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6165 | #endif |
| 6166 | {} |
| 6167 | }; |
| 6168 | |
| 6169 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6170 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6171 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6172 | {} |
| 6173 | }; |
| 6174 | |
| 6175 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6176 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6177 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6178 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6179 | int val; |
| 6180 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6181 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6182 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6183 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6184 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6185 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6186 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6187 | } |
| 6188 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6189 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6190 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6191 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6192 | } |
| 6193 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6194 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6195 | val = alc_read_coef_idx(codec, 0x04); |
| 6196 | /* Power up output pin */ |
| 6197 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6198 | } |
| 6199 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6200 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6201 | val = alc_read_coef_idx(codec, 0xd); |
| 6202 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6203 | /* Capless ramp up clock control */ |
| 6204 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6205 | } |
| 6206 | val = alc_read_coef_idx(codec, 0x17); |
| 6207 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6208 | /* Class D power on reset */ |
| 6209 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6210 | } |
| 6211 | } |
| 6212 | |
| 6213 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6214 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6215 | |
| 6216 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6217 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6218 | } |
| 6219 | |
| 6220 | /* |
| 6221 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6222 | static int patch_alc269(struct hda_codec *codec) |
| 6223 | { |
| 6224 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6225 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6226 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6227 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6228 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6229 | return err; |
| 6230 | |
| 6231 | spec = codec->spec; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6232 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6233 | if (codec->vendor_id == 0x10ec0269) { |
| 6234 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6235 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6236 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6237 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6238 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6239 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6240 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6241 | break; |
| 6242 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6243 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6244 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6245 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6246 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6247 | break; |
| 6248 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6249 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6250 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6251 | if (err < 0) |
| 6252 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6253 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6254 | alc269_fill_coef(codec); |
| 6255 | } |
| 6256 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6257 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6258 | alc269_fixup_tbl, alc269_fixups); |
| 6259 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6260 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 6261 | alc_auto_parse_customize_define(codec); |
| 6262 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6263 | /* automatic parse from the BIOS config */ |
| 6264 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6265 | if (err < 0) |
| 6266 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6267 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6268 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6269 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6270 | if (err < 0) |
| 6271 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6272 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6273 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6274 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6275 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6276 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6277 | codec->patch_ops.resume = alc269_resume; |
| 6278 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6279 | spec->shutup = alc269_shutup; |
| 6280 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6281 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6282 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6283 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6284 | |
| 6285 | error: |
| 6286 | alc_free(codec); |
| 6287 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6288 | } |
| 6289 | |
| 6290 | /* |
| 6291 | * ALC861 |
| 6292 | */ |
| 6293 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6294 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6295 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6296 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6297 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6298 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6299 | } |
| 6300 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6301 | /* Pin config fixes */ |
| 6302 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6303 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6304 | ALC861_FIXUP_AMP_VREF_0F, |
| 6305 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6306 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6307 | }; |
| 6308 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6309 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6310 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6311 | const struct alc_fixup *fix, int action) |
| 6312 | { |
| 6313 | struct alc_spec *spec = codec->spec; |
| 6314 | unsigned int val; |
| 6315 | |
| 6316 | if (action != ALC_FIXUP_ACT_INIT) |
| 6317 | return; |
| 6318 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6319 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6320 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6321 | val |= AC_PINCTL_IN_EN; |
| 6322 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6323 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6324 | spec->keep_vref_in_automute = 1; |
| 6325 | } |
| 6326 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6327 | /* suppress the jack-detection */ |
| 6328 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6329 | const struct alc_fixup *fix, int action) |
| 6330 | { |
| 6331 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6332 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6333 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6334 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6335 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6336 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6337 | .type = ALC_FIXUP_PINS, |
| 6338 | .v.pins = (const struct alc_pincfg[]) { |
| 6339 | { 0x0b, 0x0221101f }, /* HP */ |
| 6340 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6341 | { } |
| 6342 | } |
| 6343 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6344 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6345 | .type = ALC_FIXUP_FUNC, |
| 6346 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6347 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6348 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6349 | .type = ALC_FIXUP_FUNC, |
| 6350 | .v.func = alc_fixup_no_jack_detect, |
| 6351 | }, |
| 6352 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6353 | .type = ALC_FIXUP_FUNC, |
| 6354 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6355 | .chained = true, |
| 6356 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6357 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6358 | }; |
| 6359 | |
| 6360 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6361 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6362 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6363 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6364 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6365 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6366 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6367 | {} |
| 6368 | }; |
| 6369 | |
| 6370 | /* |
| 6371 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6372 | static int patch_alc861(struct hda_codec *codec) |
| 6373 | { |
| 6374 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6375 | int err; |
| 6376 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6377 | err = alc_alloc_spec(codec, 0x15); |
| 6378 | if (err < 0) |
| 6379 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6380 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6381 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6382 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6383 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6384 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6385 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6386 | /* automatic parse from the BIOS config */ |
| 6387 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6388 | if (err < 0) |
| 6389 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6390 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6391 | if (!spec->no_analog) { |
| 6392 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6393 | if (err < 0) |
| 6394 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6395 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6396 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6397 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6398 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6399 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6400 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6401 | #endif |
| 6402 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6403 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6404 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6405 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6406 | |
| 6407 | error: |
| 6408 | alc_free(codec); |
| 6409 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6410 | } |
| 6411 | |
| 6412 | /* |
| 6413 | * ALC861-VD support |
| 6414 | * |
| 6415 | * Based on ALC882 |
| 6416 | * |
| 6417 | * In addition, an independent DAC |
| 6418 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6419 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6420 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6421 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6422 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6423 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6424 | } |
| 6425 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6426 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6427 | ALC660VD_FIX_ASUS_GPIO1, |
| 6428 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6429 | }; |
| 6430 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6431 | /* exclude VREF80 */ |
| 6432 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6433 | const struct alc_fixup *fix, int action) |
| 6434 | { |
| 6435 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 6436 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 6437 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 6438 | } |
| 6439 | } |
| 6440 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6441 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6442 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6443 | .type = ALC_FIXUP_VERBS, |
| 6444 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6445 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6446 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6447 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6448 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6449 | { } |
| 6450 | } |
| 6451 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6452 | [ALC861VD_FIX_DALLAS] = { |
| 6453 | .type = ALC_FIXUP_FUNC, |
| 6454 | .v.func = alc861vd_fixup_dallas, |
| 6455 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6456 | }; |
| 6457 | |
| 6458 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6459 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6460 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6461 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6462 | {} |
| 6463 | }; |
| 6464 | |
| 6465 | static const struct hda_verb alc660vd_eapd_verbs[] = { |
| 6466 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6467 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6468 | { } |
| 6469 | }; |
| 6470 | |
| 6471 | /* |
| 6472 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6473 | static int patch_alc861vd(struct hda_codec *codec) |
| 6474 | { |
| 6475 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6476 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6477 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6478 | err = alc_alloc_spec(codec, 0x0b); |
| 6479 | if (err < 0) |
| 6480 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6481 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6482 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6483 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6484 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6485 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6486 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6487 | /* automatic parse from the BIOS config */ |
| 6488 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6489 | if (err < 0) |
| 6490 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6491 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6492 | if (codec->vendor_id == 0x10ec0660) { |
| 6493 | /* always turn on EAPD */ |
| 6494 | add_verb(spec, alc660vd_eapd_verbs); |
| 6495 | } |
| 6496 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6497 | if (!spec->no_analog) { |
| 6498 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6499 | if (err < 0) |
| 6500 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6501 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6502 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6503 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6504 | codec->patch_ops = alc_patch_ops; |
| 6505 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6506 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6507 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6508 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6509 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6510 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6511 | |
| 6512 | error: |
| 6513 | alc_free(codec); |
| 6514 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6515 | } |
| 6516 | |
| 6517 | /* |
| 6518 | * ALC662 support |
| 6519 | * |
| 6520 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6521 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6522 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6523 | * 6-channel independent captures. |
| 6524 | * |
| 6525 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6526 | * driver yet). |
| 6527 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6528 | |
| 6529 | /* |
| 6530 | * BIOS auto configuration |
| 6531 | */ |
| 6532 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6533 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6534 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6535 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6536 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6537 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6538 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6539 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6540 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6541 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6542 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6543 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6544 | ssids = alc662_ssids; |
| 6545 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6546 | } |
| 6547 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6548 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6549 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6550 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6551 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6552 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6553 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6554 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6555 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6556 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6557 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6558 | printk(KERN_WARNING |
| 6559 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6560 | } |
| 6561 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6562 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6563 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6564 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6565 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6566 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6567 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6568 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6569 | ALC662_FIXUP_ASUS_MODE1, |
| 6570 | ALC662_FIXUP_ASUS_MODE2, |
| 6571 | ALC662_FIXUP_ASUS_MODE3, |
| 6572 | ALC662_FIXUP_ASUS_MODE4, |
| 6573 | ALC662_FIXUP_ASUS_MODE5, |
| 6574 | ALC662_FIXUP_ASUS_MODE6, |
| 6575 | ALC662_FIXUP_ASUS_MODE7, |
| 6576 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6577 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6578 | }; |
| 6579 | |
| 6580 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6581 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6582 | .type = ALC_FIXUP_PINS, |
| 6583 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6584 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6585 | { } |
| 6586 | } |
| 6587 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6588 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6589 | .type = ALC_FIXUP_PINS, |
| 6590 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6591 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6592 | { } |
| 6593 | } |
| 6594 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6595 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6596 | .type = ALC_FIXUP_FUNC, |
| 6597 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6598 | }, |
| 6599 | [ALC662_FIXUP_CZC_P10T] = { |
| 6600 | .type = ALC_FIXUP_VERBS, |
| 6601 | .v.verbs = (const struct hda_verb[]) { |
| 6602 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6603 | {} |
| 6604 | } |
| 6605 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6606 | [ALC662_FIXUP_SKU_IGNORE] = { |
| 6607 | .type = ALC_FIXUP_SKU, |
| 6608 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6609 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6610 | [ALC662_FIXUP_HP_RP5800] = { |
| 6611 | .type = ALC_FIXUP_PINS, |
| 6612 | .v.pins = (const struct alc_pincfg[]) { |
| 6613 | { 0x14, 0x0221201f }, /* HP out */ |
| 6614 | { } |
| 6615 | }, |
| 6616 | .chained = true, |
| 6617 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6618 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6619 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6620 | .type = ALC_FIXUP_PINS, |
| 6621 | .v.pins = (const struct alc_pincfg[]) { |
| 6622 | { 0x14, 0x99130110 }, /* speaker */ |
| 6623 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6624 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6625 | { 0x21, 0x0121401f }, /* HP out */ |
| 6626 | { } |
| 6627 | }, |
| 6628 | .chained = true, |
| 6629 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6630 | }, |
| 6631 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6632 | .type = ALC_FIXUP_PINS, |
| 6633 | .v.pins = (const struct alc_pincfg[]) { |
| 6634 | { 0x14, 0x99130110 }, /* speaker */ |
| 6635 | { 0x18, 0x01a19820 }, /* mic */ |
| 6636 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6637 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6638 | { } |
| 6639 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6640 | .chained = true, |
| 6641 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6642 | }, |
| 6643 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6644 | .type = ALC_FIXUP_PINS, |
| 6645 | .v.pins = (const struct alc_pincfg[]) { |
| 6646 | { 0x14, 0x99130110 }, /* speaker */ |
| 6647 | { 0x15, 0x0121441f }, /* HP */ |
| 6648 | { 0x18, 0x01a19840 }, /* mic */ |
| 6649 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6650 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6651 | { } |
| 6652 | }, |
| 6653 | .chained = true, |
| 6654 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6655 | }, |
| 6656 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6657 | .type = ALC_FIXUP_PINS, |
| 6658 | .v.pins = (const struct alc_pincfg[]) { |
| 6659 | { 0x14, 0x99130110 }, /* speaker */ |
| 6660 | { 0x16, 0x99130111 }, /* speaker */ |
| 6661 | { 0x18, 0x01a19840 }, /* mic */ |
| 6662 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6663 | { 0x21, 0x0121441f }, /* HP */ |
| 6664 | { } |
| 6665 | }, |
| 6666 | .chained = true, |
| 6667 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6668 | }, |
| 6669 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6670 | .type = ALC_FIXUP_PINS, |
| 6671 | .v.pins = (const struct alc_pincfg[]) { |
| 6672 | { 0x14, 0x99130110 }, /* speaker */ |
| 6673 | { 0x15, 0x0121441f }, /* HP */ |
| 6674 | { 0x16, 0x99130111 }, /* speaker */ |
| 6675 | { 0x18, 0x01a19840 }, /* mic */ |
| 6676 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6677 | { } |
| 6678 | }, |
| 6679 | .chained = true, |
| 6680 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6681 | }, |
| 6682 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6683 | .type = ALC_FIXUP_PINS, |
| 6684 | .v.pins = (const struct alc_pincfg[]) { |
| 6685 | { 0x14, 0x99130110 }, /* speaker */ |
| 6686 | { 0x15, 0x01211420 }, /* HP2 */ |
| 6687 | { 0x18, 0x01a19840 }, /* mic */ |
| 6688 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6689 | { 0x1b, 0x0121441f }, /* HP */ |
| 6690 | { } |
| 6691 | }, |
| 6692 | .chained = true, |
| 6693 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6694 | }, |
| 6695 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 6696 | .type = ALC_FIXUP_PINS, |
| 6697 | .v.pins = (const struct alc_pincfg[]) { |
| 6698 | { 0x14, 0x99130110 }, /* speaker */ |
| 6699 | { 0x17, 0x99130111 }, /* speaker */ |
| 6700 | { 0x18, 0x01a19840 }, /* mic */ |
| 6701 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6702 | { 0x1b, 0x01214020 }, /* HP */ |
| 6703 | { 0x21, 0x0121401f }, /* HP */ |
| 6704 | { } |
| 6705 | }, |
| 6706 | .chained = true, |
| 6707 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6708 | }, |
| 6709 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6710 | .type = ALC_FIXUP_PINS, |
| 6711 | .v.pins = (const struct alc_pincfg[]) { |
| 6712 | { 0x14, 0x99130110 }, /* speaker */ |
| 6713 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6714 | { 0x15, 0x01214020 }, /* HP */ |
| 6715 | { 0x17, 0x99130111 }, /* speaker */ |
| 6716 | { 0x18, 0x01a19840 }, /* mic */ |
| 6717 | { 0x21, 0x0121401f }, /* HP */ |
| 6718 | { } |
| 6719 | }, |
| 6720 | .chained = true, |
| 6721 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6722 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6723 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 6724 | .type = ALC_FIXUP_FUNC, |
| 6725 | .v.func = alc_fixup_no_jack_detect, |
| 6726 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6727 | }; |
| 6728 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6729 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6730 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6731 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6732 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6733 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6734 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6735 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6736 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6737 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6738 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6739 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6740 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6741 | |
| 6742 | #if 0 |
| 6743 | /* Below is a quirk table taken from the old code. |
| 6744 | * Basically the device should work as is without the fixup table. |
| 6745 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6746 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6747 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6748 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6749 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6750 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6751 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6752 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6753 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6754 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6755 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6756 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6757 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6758 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6759 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6760 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6761 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6762 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6763 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6764 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6765 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6766 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6767 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6768 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6769 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6770 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6771 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6772 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6773 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6774 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6775 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6776 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6777 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 6778 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6779 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6780 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 6781 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 6782 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 6783 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 6784 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 6785 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 6786 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 6787 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6788 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 6789 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 6790 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6791 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 6792 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 6793 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 6794 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 6795 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 6796 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6797 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 6798 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6799 | {} |
| 6800 | }; |
| 6801 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6802 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 6803 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6804 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 6805 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 6806 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 6807 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 6808 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 6809 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 6810 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 6811 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6812 | {} |
| 6813 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6814 | |
| 6815 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6816 | /* |
| 6817 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6818 | static int patch_alc662(struct hda_codec *codec) |
| 6819 | { |
| 6820 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6821 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6822 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6823 | err = alc_alloc_spec(codec, 0x0b); |
| 6824 | if (err < 0) |
| 6825 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6826 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6827 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6828 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6829 | /* handle multiple HPs as is */ |
| 6830 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6831 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 6832 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6833 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6834 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6835 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6836 | spec->cdefine.platform_type == 1) { |
| 6837 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 6838 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6839 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6840 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6841 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6842 | alc662_fixup_tbl, alc662_fixups); |
| 6843 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 6844 | |
| 6845 | alc_auto_parse_customize_define(codec); |
| 6846 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6847 | /* automatic parse from the BIOS config */ |
| 6848 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6849 | if (err < 0) |
| 6850 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6851 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6852 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6853 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6854 | if (err < 0) |
| 6855 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6856 | switch (codec->vendor_id) { |
| 6857 | case 0x10ec0662: |
| 6858 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6859 | break; |
| 6860 | case 0x10ec0272: |
| 6861 | case 0x10ec0663: |
| 6862 | case 0x10ec0665: |
| 6863 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 6864 | break; |
| 6865 | case 0x10ec0273: |
| 6866 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 6867 | break; |
| 6868 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6869 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 6870 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6871 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 6872 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6873 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6874 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6875 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6876 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6877 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6878 | error: |
| 6879 | alc_free(codec); |
| 6880 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 6881 | } |
| 6882 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6883 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6884 | * ALC680 support |
| 6885 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6886 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6887 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 6888 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6889 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6890 | } |
| 6891 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6892 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6893 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6894 | static int patch_alc680(struct hda_codec *codec) |
| 6895 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6896 | int err; |
| 6897 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6898 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame^] | 6899 | err = alc_alloc_spec(codec, 0); |
| 6900 | if (err < 0) |
| 6901 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6902 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 6903 | /* automatic parse from the BIOS config */ |
| 6904 | err = alc680_parse_auto_config(codec); |
| 6905 | if (err < 0) { |
| 6906 | alc_free(codec); |
| 6907 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6908 | } |
| 6909 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6910 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6911 | |
| 6912 | return 0; |
| 6913 | } |
| 6914 | |
| 6915 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6916 | * patch entries |
| 6917 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6918 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6919 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6920 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6921 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6922 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 6923 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6924 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6925 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 6926 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6927 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6928 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6929 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6930 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6931 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 6932 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 6933 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6934 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6935 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6936 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 6937 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 6938 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 6939 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 6940 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6941 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6942 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6943 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6944 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6945 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6946 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 6947 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6948 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 6949 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6950 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6951 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6952 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 6953 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6954 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6955 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6956 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6957 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6958 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6959 | {} /* terminator */ |
| 6960 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6961 | |
| 6962 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 6963 | |
| 6964 | MODULE_LICENSE("GPL"); |
| 6965 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 6966 | |
| 6967 | static struct hda_codec_preset_list realtek_list = { |
| 6968 | .preset = snd_hda_preset_realtek, |
| 6969 | .owner = THIS_MODULE, |
| 6970 | }; |
| 6971 | |
| 6972 | static int __init patch_realtek_init(void) |
| 6973 | { |
| 6974 | return snd_hda_add_codec_preset(&realtek_list); |
| 6975 | } |
| 6976 | |
| 6977 | static void __exit patch_realtek_exit(void) |
| 6978 | { |
| 6979 | snd_hda_delete_codec_preset(&realtek_list); |
| 6980 | } |
| 6981 | |
| 6982 | module_init(patch_realtek_init) |
| 6983 | module_exit(patch_realtek_exit) |