Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
| 4 | * HD audio interface patch for SigmaTel STAC92xx |
| 5 | * |
| 6 | * Copyright (c) 2005 Embedded Alley Solutions, Inc. |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 7 | * Matt Porter <mporter@embeddedalley.com> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 8 | * |
| 9 | * Based on patch_cmedia.c and patch_realtek.c |
| 10 | * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> |
| 11 | * |
| 12 | * This driver is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This driver is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <sound/driver.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/delay.h> |
| 30 | #include <linux/slab.h> |
| 31 | #include <linux/pci.h> |
| 32 | #include <sound/core.h> |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 33 | #include <sound/asoundef.h> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 34 | #include "hda_codec.h" |
| 35 | #include "hda_local.h" |
| 36 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 37 | #define NUM_CONTROL_ALLOC 32 |
| 38 | #define STAC_HP_EVENT 0x37 |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 39 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 40 | enum { |
| 41 | STAC_REF, |
| 42 | STAC_9200_MODELS |
| 43 | }; |
| 44 | |
| 45 | enum { |
| 46 | STAC_9205_REF, |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 47 | STAC_M43xx, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 48 | STAC_9205_MODELS |
| 49 | }; |
| 50 | |
| 51 | enum { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 52 | STAC_925x_REF, |
| 53 | STAC_M2_2, |
| 54 | STAC_MA6, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 55 | STAC_PA6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 56 | STAC_925x_MODELS |
| 57 | }; |
| 58 | |
| 59 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 60 | STAC_D945_REF, |
| 61 | STAC_D945GTP3, |
| 62 | STAC_D945GTP5, |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 63 | STAC_922X_DELL, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 64 | STAC_INTEL_MAC_V1, |
| 65 | STAC_INTEL_MAC_V2, |
| 66 | STAC_INTEL_MAC_V3, |
| 67 | STAC_INTEL_MAC_V4, |
| 68 | STAC_INTEL_MAC_V5, |
| 69 | /* for backward compitability */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 70 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 71 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 72 | STAC_MACBOOK_PRO_V1, |
| 73 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 74 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 75 | STAC_IMAC_INTEL_20, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 76 | STAC_922X_MODELS |
| 77 | }; |
| 78 | |
| 79 | enum { |
| 80 | STAC_D965_REF, |
| 81 | STAC_D965_3ST, |
| 82 | STAC_D965_5ST, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 83 | STAC_DELL_3ST, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 84 | STAC_927X_MODELS |
| 85 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 86 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 87 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 88 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 89 | unsigned int num_mixers; |
| 90 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 91 | int board_config; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 92 | unsigned int surr_switch: 1; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 93 | unsigned int line_switch: 1; |
| 94 | unsigned int mic_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 95 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 96 | unsigned int hp_detect: 1; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 97 | unsigned int gpio_mute: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 98 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 99 | unsigned int gpio_mask, gpio_data; |
| 100 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 101 | /* playback */ |
| 102 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 103 | hda_nid_t dac_nids[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 104 | |
| 105 | /* capture */ |
| 106 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 107 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 108 | hda_nid_t *mux_nids; |
| 109 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 110 | hda_nid_t *dmic_nids; |
| 111 | unsigned int num_dmics; |
| 112 | hda_nid_t dmux_nid; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 113 | hda_nid_t dig_in_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 114 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 115 | /* pin widgets */ |
| 116 | hda_nid_t *pin_nids; |
| 117 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 118 | unsigned int *pin_configs; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 119 | unsigned int *bios_pin_configs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 120 | |
| 121 | /* codec specific stuff */ |
| 122 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 123 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 124 | |
| 125 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 126 | struct hda_input_mux *dinput_mux; |
| 127 | unsigned int cur_dmux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 128 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 129 | unsigned int cur_mux[3]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 130 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 131 | /* i/o switches */ |
| 132 | unsigned int io_switch[2]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 133 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 134 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 135 | |
| 136 | /* dynamic controls and input_mux */ |
| 137 | struct auto_pin_cfg autocfg; |
| 138 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 139 | struct snd_kcontrol_new *kctl_alloc; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 140 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 141 | struct hda_input_mux private_imux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | static hda_nid_t stac9200_adc_nids[1] = { |
| 145 | 0x03, |
| 146 | }; |
| 147 | |
| 148 | static hda_nid_t stac9200_mux_nids[1] = { |
| 149 | 0x0c, |
| 150 | }; |
| 151 | |
| 152 | static hda_nid_t stac9200_dac_nids[1] = { |
| 153 | 0x02, |
| 154 | }; |
| 155 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 156 | static hda_nid_t stac925x_adc_nids[1] = { |
| 157 | 0x03, |
| 158 | }; |
| 159 | |
| 160 | static hda_nid_t stac925x_mux_nids[1] = { |
| 161 | 0x0f, |
| 162 | }; |
| 163 | |
| 164 | static hda_nid_t stac925x_dac_nids[1] = { |
| 165 | 0x02, |
| 166 | }; |
| 167 | |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 168 | static hda_nid_t stac925x_dmic_nids[1] = { |
| 169 | 0x15, |
| 170 | }; |
| 171 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 172 | static hda_nid_t stac922x_adc_nids[2] = { |
| 173 | 0x06, 0x07, |
| 174 | }; |
| 175 | |
| 176 | static hda_nid_t stac922x_mux_nids[2] = { |
| 177 | 0x12, 0x13, |
| 178 | }; |
| 179 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 180 | static hda_nid_t stac927x_adc_nids[3] = { |
| 181 | 0x07, 0x08, 0x09 |
| 182 | }; |
| 183 | |
| 184 | static hda_nid_t stac927x_mux_nids[3] = { |
| 185 | 0x15, 0x16, 0x17 |
| 186 | }; |
| 187 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 188 | static hda_nid_t stac9205_adc_nids[2] = { |
| 189 | 0x12, 0x13 |
| 190 | }; |
| 191 | |
| 192 | static hda_nid_t stac9205_mux_nids[2] = { |
| 193 | 0x19, 0x1a |
| 194 | }; |
| 195 | |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 196 | static hda_nid_t stac9205_dmic_nids[2] = { |
| 197 | 0x17, 0x18, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 198 | }; |
| 199 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 200 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 201 | 0x08, 0x09, 0x0d, 0x0e, |
| 202 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 203 | }; |
| 204 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 205 | static hda_nid_t stac925x_pin_nids[8] = { |
| 206 | 0x07, 0x08, 0x0a, 0x0b, |
| 207 | 0x0c, 0x0d, 0x10, 0x11, |
| 208 | }; |
| 209 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 210 | static hda_nid_t stac922x_pin_nids[10] = { |
| 211 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 212 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 213 | }; |
| 214 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 215 | static hda_nid_t stac927x_pin_nids[14] = { |
| 216 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 217 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 218 | 0x14, 0x21, 0x22, 0x23, |
| 219 | }; |
| 220 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 221 | static hda_nid_t stac9205_pin_nids[12] = { |
| 222 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 223 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 224 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 225 | }; |
| 226 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 227 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 228 | struct snd_ctl_elem_info *uinfo) |
| 229 | { |
| 230 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 231 | struct sigmatel_spec *spec = codec->spec; |
| 232 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 233 | } |
| 234 | |
| 235 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 236 | struct snd_ctl_elem_value *ucontrol) |
| 237 | { |
| 238 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 239 | struct sigmatel_spec *spec = codec->spec; |
| 240 | |
| 241 | ucontrol->value.enumerated.item[0] = spec->cur_dmux; |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 246 | struct snd_ctl_elem_value *ucontrol) |
| 247 | { |
| 248 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 249 | struct sigmatel_spec *spec = codec->spec; |
| 250 | |
| 251 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
| 252 | spec->dmux_nid, &spec->cur_dmux); |
| 253 | } |
| 254 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 255 | static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 256 | { |
| 257 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 258 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 259 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 260 | } |
| 261 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 262 | static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 263 | { |
| 264 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 265 | struct sigmatel_spec *spec = codec->spec; |
| 266 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 267 | |
| 268 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 269 | return 0; |
| 270 | } |
| 271 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 272 | static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 273 | { |
| 274 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 275 | struct sigmatel_spec *spec = codec->spec; |
| 276 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 277 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 278 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 279 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 280 | } |
| 281 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 282 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 283 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 284 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 285 | {} |
| 286 | }; |
| 287 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 288 | static struct hda_verb stac925x_core_init[] = { |
| 289 | /* set dac0mux for dac converter */ |
| 290 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 291 | {} |
| 292 | }; |
| 293 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 294 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 295 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 296 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 297 | {} |
| 298 | }; |
| 299 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 300 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 301 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 302 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 303 | /* unmute node 0x1b */ |
| 304 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 305 | /* select node 0x03 as DAC */ |
| 306 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 307 | {} |
| 308 | }; |
| 309 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 310 | static struct hda_verb stac927x_core_init[] = { |
| 311 | /* set master volume and direct control */ |
| 312 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 313 | {} |
| 314 | }; |
| 315 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 316 | static struct hda_verb stac9205_core_init[] = { |
| 317 | /* set master volume and direct control */ |
| 318 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 319 | {} |
| 320 | }; |
| 321 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 322 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 323 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 324 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
| 325 | { |
| 326 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 327 | .name = "Input Source", |
| 328 | .count = 1, |
| 329 | .info = stac92xx_mux_enum_info, |
| 330 | .get = stac92xx_mux_enum_get, |
| 331 | .put = stac92xx_mux_enum_put, |
| 332 | }, |
| 333 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 334 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 335 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 336 | { } /* end */ |
| 337 | }; |
| 338 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 339 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 340 | { |
| 341 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 342 | .name = "Input Source", |
| 343 | .count = 1, |
| 344 | .info = stac92xx_mux_enum_info, |
| 345 | .get = stac92xx_mux_enum_get, |
| 346 | .put = stac92xx_mux_enum_put, |
| 347 | }, |
| 348 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
| 349 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT), |
| 350 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT), |
| 351 | { } /* end */ |
| 352 | }; |
| 353 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 354 | /* This needs to be generated dynamically based on sequence */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 355 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 356 | { |
| 357 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 358 | .name = "Input Source", |
| 359 | .count = 1, |
| 360 | .info = stac92xx_mux_enum_info, |
| 361 | .get = stac92xx_mux_enum_get, |
| 362 | .put = stac92xx_mux_enum_put, |
| 363 | }, |
| 364 | HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), |
Takashi Iwai | 0fd1708 | 2006-01-13 18:46:21 +0100 | [diff] [blame] | 365 | HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 366 | HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 367 | { } /* end */ |
| 368 | }; |
| 369 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 370 | /* This needs to be generated dynamically based on sequence */ |
| 371 | static struct snd_kcontrol_new stac9227_mixer[] = { |
| 372 | { |
| 373 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 374 | .name = "Input Source", |
| 375 | .count = 1, |
| 376 | .info = stac92xx_mux_enum_info, |
| 377 | .get = stac92xx_mux_enum_get, |
| 378 | .put = stac92xx_mux_enum_put, |
| 379 | }, |
| 380 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 381 | HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 382 | { } /* end */ |
| 383 | }; |
| 384 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 385 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 386 | { |
| 387 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 388 | .name = "Input Source", |
| 389 | .count = 1, |
| 390 | .info = stac92xx_mux_enum_info, |
| 391 | .get = stac92xx_mux_enum_get, |
| 392 | .put = stac92xx_mux_enum_put, |
| 393 | }, |
| 394 | HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 395 | HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT), |
| 396 | HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 397 | { } /* end */ |
| 398 | }; |
| 399 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 400 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 401 | { |
| 402 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 403 | .name = "Digital Input Source", |
| 404 | .count = 1, |
| 405 | .info = stac92xx_dmux_enum_info, |
| 406 | .get = stac92xx_dmux_enum_get, |
| 407 | .put = stac92xx_dmux_enum_put, |
| 408 | }, |
| 409 | { |
| 410 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 411 | .name = "Input Source", |
| 412 | .count = 1, |
| 413 | .info = stac92xx_mux_enum_info, |
| 414 | .get = stac92xx_mux_enum_get, |
| 415 | .put = stac92xx_mux_enum_put, |
| 416 | }, |
| 417 | HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT), |
| 418 | HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 419 | HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 420 | { } /* end */ |
| 421 | }; |
| 422 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 423 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 424 | { |
| 425 | struct sigmatel_spec *spec = codec->spec; |
| 426 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 427 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 428 | |
| 429 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 430 | if (err < 0) |
| 431 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 432 | |
| 433 | for (i = 0; i < spec->num_mixers; i++) { |
| 434 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 435 | if (err < 0) |
| 436 | return err; |
| 437 | } |
| 438 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 439 | if (spec->multiout.dig_out_nid) { |
| 440 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 441 | if (err < 0) |
| 442 | return err; |
| 443 | } |
| 444 | if (spec->dig_in_nid) { |
| 445 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 446 | if (err < 0) |
| 447 | return err; |
| 448 | } |
| 449 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 450 | } |
| 451 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 452 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 453 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 454 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 455 | }; |
| 456 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 457 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 458 | [STAC_REF] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 459 | }; |
| 460 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 461 | static const char *stac9200_models[STAC_9200_MODELS] = { |
| 462 | [STAC_REF] = "ref", |
| 463 | }; |
| 464 | |
| 465 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 466 | /* SigmaTel reference board */ |
| 467 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 468 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 469 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 470 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
| 471 | "Dell Inspiron 630m", STAC_REF), |
| 472 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
| 473 | "Dell Latitude D620", STAC_REF), |
| 474 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
| 475 | "Dell Latitude 120L", STAC_REF), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 476 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
| 477 | "Dell Latitude D820", STAC_REF), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 478 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
| 479 | "Dell Inspiron E1705/9400", STAC_REF), |
| 480 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
| 481 | "Dell XPS M1710", STAC_REF), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 482 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
| 483 | "Dell Precision M90", STAC_REF), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 484 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
| 485 | "unknown Dell", STAC_REF), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 486 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
| 487 | "Dell Inspiron 640m", STAC_REF), |
| 488 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
| 489 | "Dell Inspiron 1501", STAC_REF), |
| 490 | |
| 491 | /* Panasonic */ |
| 492 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF), |
| 493 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 494 | {} /* terminator */ |
| 495 | }; |
| 496 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 497 | static unsigned int ref925x_pin_configs[8] = { |
| 498 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 499 | 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e, |
| 500 | }; |
| 501 | |
| 502 | static unsigned int stac925x_MA6_pin_configs[8] = { |
| 503 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 504 | 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, |
| 505 | }; |
| 506 | |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 507 | static unsigned int stac925x_PA6_pin_configs[8] = { |
| 508 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 509 | 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e, |
| 510 | }; |
| 511 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 512 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Steve Longerbeam | 7353e14 | 2007-05-29 14:36:17 +0200 | [diff] [blame] | 513 | 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020, |
| 514 | 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 515 | }; |
| 516 | |
| 517 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 518 | [STAC_REF] = ref925x_pin_configs, |
| 519 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
| 520 | [STAC_MA6] = stac925x_MA6_pin_configs, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 521 | [STAC_PA6] = stac925x_PA6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 522 | }; |
| 523 | |
| 524 | static const char *stac925x_models[STAC_925x_MODELS] = { |
| 525 | [STAC_REF] = "ref", |
| 526 | [STAC_M2_2] = "m2-2", |
| 527 | [STAC_MA6] = "m6", |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 528 | [STAC_PA6] = "pa6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 529 | }; |
| 530 | |
| 531 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 532 | /* SigmaTel reference board */ |
| 533 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 534 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 535 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), |
| 536 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), |
| 537 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 538 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 539 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2), |
| 540 | {} /* terminator */ |
| 541 | }; |
| 542 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 543 | static unsigned int ref922x_pin_configs[10] = { |
| 544 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 545 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 546 | 0x40000100, 0x40000100, |
| 547 | }; |
| 548 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 549 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 550 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 551 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 552 | 0x02a19120, 0x40000100, |
| 553 | }; |
| 554 | |
| 555 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 556 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 557 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 558 | 0x02a19320, 0x40000100, |
| 559 | }; |
| 560 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 561 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 562 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 563 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 564 | 0x400000fc, 0x400000fb, |
| 565 | }; |
| 566 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 567 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 568 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 569 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 570 | 0x400000fc, 0x400000fb, |
| 571 | }; |
| 572 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 573 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 574 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 575 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 576 | 0x400000fc, 0x400000fb, |
| 577 | }; |
| 578 | |
| 579 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 580 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 581 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 582 | 0x400000fc, 0x400000fb, |
| 583 | }; |
| 584 | |
| 585 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 586 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 587 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 588 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 589 | }; |
| 590 | |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 591 | static unsigned int stac922x_dell_pin_configs[10] = { |
| 592 | 0x0221121e, 0x408103ff, 0x02a1123e, 0x90100310, |
| 593 | 0x408003f1, 0x0221122f, 0x03451340, 0x40c003f2, |
| 594 | 0x50a003f3, 0x405003f4 |
| 595 | }; |
| 596 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 597 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 598 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 599 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 600 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 601 | [STAC_922X_DELL] = stac922x_dell_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 602 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 603 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 604 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 605 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 606 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
| 607 | /* for backward compitability */ |
| 608 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 609 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 610 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 611 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 612 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 613 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 614 | }; |
| 615 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 616 | static const char *stac922x_models[STAC_922X_MODELS] = { |
| 617 | [STAC_D945_REF] = "ref", |
| 618 | [STAC_D945GTP5] = "5stack", |
| 619 | [STAC_D945GTP3] = "3stack", |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 620 | [STAC_922X_DELL] = "dell", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 621 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 622 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 623 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 624 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 625 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
| 626 | /* for backward compitability */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 627 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 628 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 629 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 630 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 631 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 632 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 633 | }; |
| 634 | |
| 635 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 636 | /* SigmaTel reference board */ |
| 637 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 638 | "DFI LanParty", STAC_D945_REF), |
| 639 | /* Intel 945G based systems */ |
| 640 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 641 | "Intel D945G", STAC_D945GTP3), |
| 642 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 643 | "Intel D945G", STAC_D945GTP3), |
| 644 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 645 | "Intel D945G", STAC_D945GTP3), |
| 646 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 647 | "Intel D945G", STAC_D945GTP3), |
| 648 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 649 | "Intel D945G", STAC_D945GTP3), |
| 650 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 651 | "Intel D945G", STAC_D945GTP3), |
| 652 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 653 | "Intel D945G", STAC_D945GTP3), |
| 654 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 655 | "Intel D945G", STAC_D945GTP3), |
| 656 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 657 | "Intel D945G", STAC_D945GTP3), |
| 658 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 659 | "Intel D945G", STAC_D945GTP3), |
| 660 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 661 | "Intel D945G", STAC_D945GTP3), |
| 662 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 663 | "Intel D945G", STAC_D945GTP3), |
| 664 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 665 | "Intel D945G", STAC_D945GTP3), |
| 666 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 667 | "Intel D945G", STAC_D945GTP3), |
| 668 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 669 | "Intel D945G", STAC_D945GTP3), |
| 670 | /* Intel D945G 5-stack systems */ |
| 671 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 672 | "Intel D945G", STAC_D945GTP5), |
| 673 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 674 | "Intel D945G", STAC_D945GTP5), |
| 675 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 676 | "Intel D945G", STAC_D945GTP5), |
| 677 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 678 | "Intel D945G", STAC_D945GTP5), |
| 679 | /* Intel 945P based systems */ |
| 680 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 681 | "Intel D945P", STAC_D945GTP3), |
| 682 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 683 | "Intel D945P", STAC_D945GTP3), |
| 684 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 685 | "Intel D945P", STAC_D945GTP3), |
| 686 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 687 | "Intel D945P", STAC_D945GTP3), |
| 688 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 689 | "Intel D945P", STAC_D945GTP3), |
| 690 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 691 | "Intel D945P", STAC_D945GTP5), |
| 692 | /* other systems */ |
| 693 | /* Apple Mac Mini (early 2006) */ |
| 694 | SND_PCI_QUIRK(0x8384, 0x7680, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 695 | "Mac Mini", STAC_INTEL_MAC_V3), |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 696 | /* Dell */ |
| 697 | SND_PCI_QUIRK(0x1028, 0x01d7, "Dell XPS M1210", STAC_922X_DELL), |
| 698 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 699 | {} /* terminator */ |
| 700 | }; |
| 701 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 702 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 703 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 704 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 705 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 706 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 707 | }; |
| 708 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 709 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 710 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 711 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 712 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 713 | 0x40000100, 0x40000100 |
| 714 | }; |
| 715 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 716 | static unsigned int d965_5st_pin_configs[14] = { |
| 717 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 718 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 719 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 720 | 0x40000100, 0x40000100 |
| 721 | }; |
| 722 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 723 | static unsigned int dell_3st_pin_configs[14] = { |
| 724 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 725 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
| 726 | 0x403003fa, 0x40000100, 0x40000100, 0x404003fb, |
| 727 | 0x40c003fc, 0x40000100 |
| 728 | }; |
| 729 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 730 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 731 | [STAC_D965_REF] = ref927x_pin_configs, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 732 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 733 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 734 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 735 | }; |
| 736 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 737 | static const char *stac927x_models[STAC_927X_MODELS] = { |
| 738 | [STAC_D965_REF] = "ref", |
| 739 | [STAC_D965_3ST] = "3stack", |
| 740 | [STAC_D965_5ST] = "5stack", |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 741 | [STAC_DELL_3ST] = "dell-3stack", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 742 | }; |
| 743 | |
| 744 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 745 | /* SigmaTel reference board */ |
| 746 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 747 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 748 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 749 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 750 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 751 | /* 965 based 3 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 752 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), |
| 753 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), |
| 754 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), |
| 755 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), |
| 756 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST), |
| 757 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST), |
| 758 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST), |
| 759 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST), |
| 760 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST), |
| 761 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST), |
| 762 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST), |
| 763 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST), |
| 764 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST), |
| 765 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), |
| 766 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), |
| 767 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 768 | /* Dell 3 stack systems */ |
| 769 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell E520", STAC_DELL_3ST), |
| 770 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 771 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 772 | /* 965 based 5 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 773 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), |
| 774 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), |
| 775 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), |
| 776 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), |
| 777 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST), |
| 778 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST), |
| 779 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST), |
| 780 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST), |
| 781 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 782 | {} /* terminator */ |
| 783 | }; |
| 784 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 785 | static unsigned int ref9205_pin_configs[12] = { |
| 786 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 787 | 0x01813122, 0x01a19021, 0x40000100, 0x40000100, |
| 788 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 789 | }; |
| 790 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 791 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 792 | [STAC_REF] = ref9205_pin_configs, |
| 793 | [STAC_M43xx] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 794 | }; |
| 795 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 796 | static const char *stac9205_models[STAC_9205_MODELS] = { |
| 797 | [STAC_9205_REF] = "ref", |
| 798 | }; |
| 799 | |
| 800 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 801 | /* SigmaTel reference board */ |
| 802 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 803 | "DFI LanParty", STAC_9205_REF), |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 804 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x01f8, |
| 805 | "Dell Precision", STAC_M43xx), |
| 806 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x01ff, |
| 807 | "Dell Precision", STAC_M43xx), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 808 | {} /* terminator */ |
| 809 | }; |
| 810 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 811 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) |
| 812 | { |
| 813 | int i; |
| 814 | struct sigmatel_spec *spec = codec->spec; |
| 815 | |
| 816 | if (! spec->bios_pin_configs) { |
| 817 | spec->bios_pin_configs = kcalloc(spec->num_pins, |
| 818 | sizeof(*spec->bios_pin_configs), GFP_KERNEL); |
| 819 | if (! spec->bios_pin_configs) |
| 820 | return -ENOMEM; |
| 821 | } |
| 822 | |
| 823 | for (i = 0; i < spec->num_pins; i++) { |
| 824 | hda_nid_t nid = spec->pin_nids[i]; |
| 825 | unsigned int pin_cfg; |
| 826 | |
| 827 | pin_cfg = snd_hda_codec_read(codec, nid, 0, |
| 828 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); |
| 829 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", |
| 830 | nid, pin_cfg); |
| 831 | spec->bios_pin_configs[i] = pin_cfg; |
| 832 | } |
| 833 | |
| 834 | return 0; |
| 835 | } |
| 836 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 837 | static void stac92xx_set_config_reg(struct hda_codec *codec, |
| 838 | hda_nid_t pin_nid, unsigned int pin_config) |
| 839 | { |
| 840 | int i; |
| 841 | snd_hda_codec_write(codec, pin_nid, 0, |
| 842 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, |
| 843 | pin_config & 0x000000ff); |
| 844 | snd_hda_codec_write(codec, pin_nid, 0, |
| 845 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, |
| 846 | (pin_config & 0x0000ff00) >> 8); |
| 847 | snd_hda_codec_write(codec, pin_nid, 0, |
| 848 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, |
| 849 | (pin_config & 0x00ff0000) >> 16); |
| 850 | snd_hda_codec_write(codec, pin_nid, 0, |
| 851 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, |
| 852 | pin_config >> 24); |
| 853 | i = snd_hda_codec_read(codec, pin_nid, 0, |
| 854 | AC_VERB_GET_CONFIG_DEFAULT, |
| 855 | 0x00); |
| 856 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", |
| 857 | pin_nid, i); |
| 858 | } |
| 859 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 860 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
| 861 | { |
| 862 | int i; |
| 863 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 864 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 865 | if (!spec->pin_configs) |
| 866 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 867 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 868 | for (i = 0; i < spec->num_pins; i++) |
| 869 | stac92xx_set_config_reg(codec, spec->pin_nids[i], |
| 870 | spec->pin_configs[i]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 871 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 872 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 873 | static void stac92xx_enable_gpio_mask(struct hda_codec *codec) |
Matthew Ranostay | 92a22be | 2007-06-19 16:48:28 +0200 | [diff] [blame] | 874 | { |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 875 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 876 | /* Configure GPIOx as output */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 877 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 878 | AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 879 | /* Configure GPIOx as CMOS */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 880 | snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 881 | /* Assert GPIOx */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 882 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 883 | AC_VERB_SET_GPIO_DATA, spec->gpio_data); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 884 | /* Enable GPIOx */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 885 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 886 | AC_VERB_SET_GPIO_MASK, spec->gpio_mask); |
Matthew Ranostay | 92a22be | 2007-06-19 16:48:28 +0200 | [diff] [blame] | 887 | } |
| 888 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 889 | /* |
| 890 | * Analog playback callbacks |
| 891 | */ |
| 892 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 893 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 894 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 895 | { |
| 896 | struct sigmatel_spec *spec = codec->spec; |
| 897 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 898 | } |
| 899 | |
| 900 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 901 | struct hda_codec *codec, |
| 902 | unsigned int stream_tag, |
| 903 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 904 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 905 | { |
| 906 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 907 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 911 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 912 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 913 | { |
| 914 | struct sigmatel_spec *spec = codec->spec; |
| 915 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 916 | } |
| 917 | |
| 918 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 919 | * Digital playback callbacks |
| 920 | */ |
| 921 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 922 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 923 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 924 | { |
| 925 | struct sigmatel_spec *spec = codec->spec; |
| 926 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 927 | } |
| 928 | |
| 929 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 930 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 931 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 932 | { |
| 933 | struct sigmatel_spec *spec = codec->spec; |
| 934 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 935 | } |
| 936 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 937 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 938 | struct hda_codec *codec, |
| 939 | unsigned int stream_tag, |
| 940 | unsigned int format, |
| 941 | struct snd_pcm_substream *substream) |
| 942 | { |
| 943 | struct sigmatel_spec *spec = codec->spec; |
| 944 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 945 | stream_tag, format, substream); |
| 946 | } |
| 947 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 948 | |
| 949 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 950 | * Analog capture callbacks |
| 951 | */ |
| 952 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 953 | struct hda_codec *codec, |
| 954 | unsigned int stream_tag, |
| 955 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 956 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 957 | { |
| 958 | struct sigmatel_spec *spec = codec->spec; |
| 959 | |
| 960 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 961 | stream_tag, 0, format); |
| 962 | return 0; |
| 963 | } |
| 964 | |
| 965 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 966 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 967 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 968 | { |
| 969 | struct sigmatel_spec *spec = codec->spec; |
| 970 | |
| 971 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 972 | return 0; |
| 973 | } |
| 974 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 975 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 976 | .substreams = 1, |
| 977 | .channels_min = 2, |
| 978 | .channels_max = 2, |
| 979 | /* NID is set in stac92xx_build_pcms */ |
| 980 | .ops = { |
| 981 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 982 | .close = stac92xx_dig_playback_pcm_close, |
| 983 | .prepare = stac92xx_dig_playback_pcm_prepare |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 984 | }, |
| 985 | }; |
| 986 | |
| 987 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 988 | .substreams = 1, |
| 989 | .channels_min = 2, |
| 990 | .channels_max = 2, |
| 991 | /* NID is set in stac92xx_build_pcms */ |
| 992 | }; |
| 993 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 994 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 995 | .substreams = 1, |
| 996 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 997 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 998 | .nid = 0x02, /* NID to query formats and rates */ |
| 999 | .ops = { |
| 1000 | .open = stac92xx_playback_pcm_open, |
| 1001 | .prepare = stac92xx_playback_pcm_prepare, |
| 1002 | .cleanup = stac92xx_playback_pcm_cleanup |
| 1003 | }, |
| 1004 | }; |
| 1005 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1006 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 1007 | .substreams = 1, |
| 1008 | .channels_min = 2, |
| 1009 | .channels_max = 2, |
| 1010 | .nid = 0x06, /* NID to query formats and rates */ |
| 1011 | .ops = { |
| 1012 | .open = stac92xx_playback_pcm_open, |
| 1013 | .prepare = stac92xx_playback_pcm_prepare, |
| 1014 | .cleanup = stac92xx_playback_pcm_cleanup |
| 1015 | }, |
| 1016 | }; |
| 1017 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1018 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
| 1019 | .substreams = 2, |
| 1020 | .channels_min = 2, |
| 1021 | .channels_max = 2, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1022 | /* NID is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1023 | .ops = { |
| 1024 | .prepare = stac92xx_capture_pcm_prepare, |
| 1025 | .cleanup = stac92xx_capture_pcm_cleanup |
| 1026 | }, |
| 1027 | }; |
| 1028 | |
| 1029 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 1030 | { |
| 1031 | struct sigmatel_spec *spec = codec->spec; |
| 1032 | struct hda_pcm *info = spec->pcm_rec; |
| 1033 | |
| 1034 | codec->num_pcms = 1; |
| 1035 | codec->pcm_info = info; |
| 1036 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1037 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1038 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1039 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1040 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1041 | |
| 1042 | if (spec->alt_switch) { |
| 1043 | codec->num_pcms++; |
| 1044 | info++; |
| 1045 | info->name = "STAC92xx Analog Alt"; |
| 1046 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 1047 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1048 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1049 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 1050 | codec->num_pcms++; |
| 1051 | info++; |
| 1052 | info->name = "STAC92xx Digital"; |
| 1053 | if (spec->multiout.dig_out_nid) { |
| 1054 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 1055 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 1056 | } |
| 1057 | if (spec->dig_in_nid) { |
| 1058 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 1059 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 1060 | } |
| 1061 | } |
| 1062 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1063 | return 0; |
| 1064 | } |
| 1065 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1066 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 1067 | { |
| 1068 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 1069 | AC_PAR_PIN_CAP); |
| 1070 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 1071 | if (pincap & AC_PINCAP_VREF_100) |
| 1072 | return AC_PINCTL_VREF_100; |
| 1073 | if (pincap & AC_PINCAP_VREF_80) |
| 1074 | return AC_PINCTL_VREF_80; |
| 1075 | if (pincap & AC_PINCAP_VREF_50) |
| 1076 | return AC_PINCTL_VREF_50; |
| 1077 | if (pincap & AC_PINCAP_VREF_GRD) |
| 1078 | return AC_PINCTL_VREF_GRD; |
| 1079 | return 0; |
| 1080 | } |
| 1081 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1082 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 1083 | |
| 1084 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1085 | snd_hda_codec_write_cache(codec, nid, 0, |
| 1086 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1087 | } |
| 1088 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 1089 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1090 | |
| 1091 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 1092 | { |
| 1093 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1094 | struct sigmatel_spec *spec = codec->spec; |
| 1095 | int io_idx = kcontrol-> private_value & 0xff; |
| 1096 | |
| 1097 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 1098 | return 0; |
| 1099 | } |
| 1100 | |
| 1101 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 1102 | { |
| 1103 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1104 | struct sigmatel_spec *spec = codec->spec; |
| 1105 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 1106 | int io_idx = kcontrol-> private_value & 0xff; |
| 1107 | unsigned short val = ucontrol->value.integer.value[0]; |
| 1108 | |
| 1109 | spec->io_switch[io_idx] = val; |
| 1110 | |
| 1111 | if (val) |
| 1112 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1113 | else { |
| 1114 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 1115 | if (io_idx) /* set VREF for mic */ |
| 1116 | pinctl |= stac92xx_get_vref(codec, nid); |
| 1117 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 1118 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1119 | return 1; |
| 1120 | } |
| 1121 | |
| 1122 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 1123 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1124 | .name = xname, \ |
| 1125 | .index = 0, \ |
| 1126 | .info = stac92xx_io_switch_info, \ |
| 1127 | .get = stac92xx_io_switch_get, \ |
| 1128 | .put = stac92xx_io_switch_put, \ |
| 1129 | .private_value = xpval, \ |
| 1130 | } |
| 1131 | |
| 1132 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1133 | enum { |
| 1134 | STAC_CTL_WIDGET_VOL, |
| 1135 | STAC_CTL_WIDGET_MUTE, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1136 | STAC_CTL_WIDGET_IO_SWITCH, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1137 | }; |
| 1138 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1139 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1140 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 1141 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1142 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1143 | }; |
| 1144 | |
| 1145 | /* add dynamic controls */ |
| 1146 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) |
| 1147 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1148 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1149 | |
| 1150 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 1151 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 1152 | |
| 1153 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 1154 | if (! knew) |
| 1155 | return -ENOMEM; |
| 1156 | if (spec->kctl_alloc) { |
| 1157 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 1158 | kfree(spec->kctl_alloc); |
| 1159 | } |
| 1160 | spec->kctl_alloc = knew; |
| 1161 | spec->num_kctl_alloc = num; |
| 1162 | } |
| 1163 | |
| 1164 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 1165 | *knew = stac92xx_control_templates[type]; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 1166 | knew->name = kstrdup(name, GFP_KERNEL); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1167 | if (! knew->name) |
| 1168 | return -ENOMEM; |
| 1169 | knew->private_value = val; |
| 1170 | spec->num_kctl_used++; |
| 1171 | return 0; |
| 1172 | } |
| 1173 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1174 | /* flag inputs as additional dynamic lineouts */ |
| 1175 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 1176 | { |
| 1177 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1178 | unsigned int wcaps, wtype; |
| 1179 | int i, num_dacs = 0; |
| 1180 | |
| 1181 | /* use the wcaps cache to count all DACs available for line-outs */ |
| 1182 | for (i = 0; i < codec->num_nodes; i++) { |
| 1183 | wcaps = codec->wcaps[i]; |
| 1184 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 1185 | if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) |
| 1186 | num_dacs++; |
| 1187 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1188 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1189 | snd_printdd("%s: total dac count=%d\n", __func__, num_dacs); |
| 1190 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1191 | switch (cfg->line_outs) { |
| 1192 | case 3: |
| 1193 | /* add line-in as side */ |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1194 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1195 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; |
| 1196 | spec->line_switch = 1; |
| 1197 | cfg->line_outs++; |
| 1198 | } |
| 1199 | break; |
| 1200 | case 2: |
| 1201 | /* add line-in as clfe and mic as side */ |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1202 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1203 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; |
| 1204 | spec->line_switch = 1; |
| 1205 | cfg->line_outs++; |
| 1206 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1207 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1208 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; |
| 1209 | spec->mic_switch = 1; |
| 1210 | cfg->line_outs++; |
| 1211 | } |
| 1212 | break; |
| 1213 | case 1: |
| 1214 | /* add line-in as surr and mic as clfe */ |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1215 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1216 | cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; |
| 1217 | spec->line_switch = 1; |
| 1218 | cfg->line_outs++; |
| 1219 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1220 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1221 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; |
| 1222 | spec->mic_switch = 1; |
| 1223 | cfg->line_outs++; |
| 1224 | } |
| 1225 | break; |
| 1226 | } |
| 1227 | |
| 1228 | return 0; |
| 1229 | } |
| 1230 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1231 | |
| 1232 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 1233 | { |
| 1234 | int i; |
| 1235 | |
| 1236 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 1237 | if (spec->multiout.dac_nids[i] == nid) |
| 1238 | return 1; |
| 1239 | } |
| 1240 | |
| 1241 | return 0; |
| 1242 | } |
| 1243 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1244 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1245 | * Fill in the dac_nids table from the parsed pin configuration |
| 1246 | * This function only works when every pin in line_out_pins[] |
| 1247 | * contains atleast one DAC in its connection list. Some 92xx |
| 1248 | * codecs are not connected directly to a DAC, such as the 9200 |
| 1249 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1250 | */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1251 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 1252 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1253 | { |
| 1254 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1255 | int i, j, conn_len = 0; |
| 1256 | hda_nid_t nid, conn[HDA_MAX_CONNECTIONS]; |
| 1257 | unsigned int wcaps, wtype; |
| 1258 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1259 | for (i = 0; i < cfg->line_outs; i++) { |
| 1260 | nid = cfg->line_out_pins[i]; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1261 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 1262 | HDA_MAX_CONNECTIONS); |
| 1263 | for (j = 0; j < conn_len; j++) { |
| 1264 | wcaps = snd_hda_param_read(codec, conn[j], |
| 1265 | AC_PAR_AUDIO_WIDGET_CAP); |
| 1266 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 1267 | |
| 1268 | if (wtype != AC_WID_AUD_OUT || |
| 1269 | (wcaps & AC_WCAP_DIGITAL)) |
| 1270 | continue; |
| 1271 | /* conn[j] is a DAC routed to this line-out */ |
| 1272 | if (!is_in_dac_nids(spec, conn[j])) |
| 1273 | break; |
| 1274 | } |
| 1275 | |
| 1276 | if (j == conn_len) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 1277 | if (spec->multiout.num_dacs > 0) { |
| 1278 | /* we have already working output pins, |
| 1279 | * so let's drop the broken ones again |
| 1280 | */ |
| 1281 | cfg->line_outs = spec->multiout.num_dacs; |
| 1282 | break; |
| 1283 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1284 | /* error out, no available DAC found */ |
| 1285 | snd_printk(KERN_ERR |
| 1286 | "%s: No available DAC for pin 0x%x\n", |
| 1287 | __func__, nid); |
| 1288 | return -ENODEV; |
| 1289 | } |
| 1290 | |
| 1291 | spec->multiout.dac_nids[i] = conn[j]; |
| 1292 | spec->multiout.num_dacs++; |
| 1293 | if (conn_len > 1) { |
| 1294 | /* select this DAC in the pin's input mux */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1295 | snd_hda_codec_write_cache(codec, nid, 0, |
| 1296 | AC_VERB_SET_CONNECT_SEL, j); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1297 | |
| 1298 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1299 | } |
| 1300 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1301 | snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
| 1302 | spec->multiout.num_dacs, |
| 1303 | spec->multiout.dac_nids[0], |
| 1304 | spec->multiout.dac_nids[1], |
| 1305 | spec->multiout.dac_nids[2], |
| 1306 | spec->multiout.dac_nids[3], |
| 1307 | spec->multiout.dac_nids[4]); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1308 | return 0; |
| 1309 | } |
| 1310 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1311 | /* create volume control/switch for the given prefx type */ |
| 1312 | static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) |
| 1313 | { |
| 1314 | char name[32]; |
| 1315 | int err; |
| 1316 | |
| 1317 | sprintf(name, "%s Playback Volume", pfx); |
| 1318 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 1319 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 1320 | if (err < 0) |
| 1321 | return err; |
| 1322 | sprintf(name, "%s Playback Switch", pfx); |
| 1323 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 1324 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 1325 | if (err < 0) |
| 1326 | return err; |
| 1327 | return 0; |
| 1328 | } |
| 1329 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1330 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1331 | static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, |
| 1332 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1333 | { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1334 | static const char *chname[4] = { |
| 1335 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 1336 | }; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1337 | hda_nid_t nid; |
| 1338 | int i, err; |
| 1339 | |
| 1340 | for (i = 0; i < cfg->line_outs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1341 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1342 | continue; |
| 1343 | |
| 1344 | nid = spec->multiout.dac_nids[i]; |
| 1345 | |
| 1346 | if (i == 2) { |
| 1347 | /* Center/LFE */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1348 | err = create_controls(spec, "Center", nid, 1); |
| 1349 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1350 | return err; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1351 | err = create_controls(spec, "LFE", nid, 2); |
| 1352 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1353 | return err; |
| 1354 | } else { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1355 | err = create_controls(spec, chname[i], nid, 3); |
| 1356 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1357 | return err; |
| 1358 | } |
| 1359 | } |
| 1360 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1361 | if (spec->line_switch) |
| 1362 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) |
| 1363 | return err; |
| 1364 | |
| 1365 | if (spec->mic_switch) |
| 1366 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) |
| 1367 | return err; |
| 1368 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1369 | return 0; |
| 1370 | } |
| 1371 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1372 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 1373 | { |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1374 | if (is_in_dac_nids(spec, nid)) |
| 1375 | return 1; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1376 | if (spec->multiout.hp_nid == nid) |
| 1377 | return 1; |
| 1378 | return 0; |
| 1379 | } |
| 1380 | |
| 1381 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 1382 | { |
| 1383 | if (!spec->multiout.hp_nid) |
| 1384 | spec->multiout.hp_nid = nid; |
| 1385 | else if (spec->multiout.num_dacs > 4) { |
| 1386 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 1387 | return 1; |
| 1388 | } else { |
| 1389 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 1390 | spec->multiout.num_dacs++; |
| 1391 | } |
| 1392 | return 0; |
| 1393 | } |
| 1394 | |
| 1395 | /* add playback controls for Speaker and HP outputs */ |
| 1396 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 1397 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1398 | { |
| 1399 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1400 | hda_nid_t nid; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1401 | int i, old_num_dacs, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1402 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1403 | old_num_dacs = spec->multiout.num_dacs; |
| 1404 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1405 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
| 1406 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 1407 | spec->hp_detect = 1; |
| 1408 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 1409 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1410 | if (check_in_dac_nids(spec, nid)) |
| 1411 | nid = 0; |
| 1412 | if (! nid) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1413 | continue; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1414 | add_spec_dacs(spec, nid); |
| 1415 | } |
| 1416 | for (i = 0; i < cfg->speaker_outs; i++) { |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1417 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1418 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1419 | if (check_in_dac_nids(spec, nid)) |
| 1420 | nid = 0; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1421 | if (! nid) |
| 1422 | continue; |
| 1423 | add_spec_dacs(spec, nid); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1424 | } |
Matthew Ranostay | 1b290a5 | 2007-07-12 15:17:34 +0200 | [diff] [blame] | 1425 | for (i = 0; i < cfg->line_outs; i++) { |
| 1426 | nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0, |
| 1427 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1428 | if (check_in_dac_nids(spec, nid)) |
| 1429 | nid = 0; |
| 1430 | if (! nid) |
| 1431 | continue; |
| 1432 | add_spec_dacs(spec, nid); |
| 1433 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1434 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { |
| 1435 | static const char *pfxs[] = { |
| 1436 | "Speaker", "External Speaker", "Speaker2", |
| 1437 | }; |
| 1438 | err = create_controls(spec, pfxs[i - old_num_dacs], |
| 1439 | spec->multiout.dac_nids[i], 3); |
| 1440 | if (err < 0) |
| 1441 | return err; |
| 1442 | } |
| 1443 | if (spec->multiout.hp_nid) { |
| 1444 | const char *pfx; |
| 1445 | if (old_num_dacs == spec->multiout.num_dacs) |
| 1446 | pfx = "Master"; |
| 1447 | else |
| 1448 | pfx = "Headphone"; |
| 1449 | err = create_controls(spec, pfx, spec->multiout.hp_nid, 3); |
| 1450 | if (err < 0) |
| 1451 | return err; |
| 1452 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1453 | |
| 1454 | return 0; |
| 1455 | } |
| 1456 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1457 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 1458 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1459 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 1460 | "Digital Mic 3", "Digital Mic 4" |
| 1461 | }; |
| 1462 | |
| 1463 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 1464 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 1465 | const struct auto_pin_cfg *cfg) |
| 1466 | { |
| 1467 | struct sigmatel_spec *spec = codec->spec; |
| 1468 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 1469 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 1470 | int i, j; |
| 1471 | |
| 1472 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 1473 | dimux->items[dimux->num_items].index = 0; |
| 1474 | dimux->num_items++; |
| 1475 | |
| 1476 | for (i = 0; i < spec->num_dmics; i++) { |
| 1477 | int index; |
| 1478 | int num_cons; |
| 1479 | unsigned int def_conf; |
| 1480 | |
| 1481 | def_conf = snd_hda_codec_read(codec, |
| 1482 | spec->dmic_nids[i], |
| 1483 | 0, |
| 1484 | AC_VERB_GET_CONFIG_DEFAULT, |
| 1485 | 0); |
| 1486 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 1487 | continue; |
| 1488 | |
| 1489 | num_cons = snd_hda_get_connections(codec, |
| 1490 | spec->dmux_nid, |
| 1491 | con_lst, |
| 1492 | HDA_MAX_NUM_INPUTS); |
| 1493 | for (j = 0; j < num_cons; j++) |
| 1494 | if (con_lst[j] == spec->dmic_nids[i]) { |
| 1495 | index = j; |
| 1496 | goto found; |
| 1497 | } |
| 1498 | continue; |
| 1499 | found: |
| 1500 | dimux->items[dimux->num_items].label = |
| 1501 | stac92xx_dmic_labels[dimux->num_items]; |
| 1502 | dimux->items[dimux->num_items].index = index; |
| 1503 | dimux->num_items++; |
| 1504 | } |
| 1505 | |
| 1506 | return 0; |
| 1507 | } |
| 1508 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1509 | /* create playback/capture controls for input pins */ |
| 1510 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 1511 | { |
| 1512 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1513 | struct hda_input_mux *imux = &spec->private_imux; |
| 1514 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 1515 | int i, j, k; |
| 1516 | |
| 1517 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1518 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1519 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1520 | if (!cfg->input_pins[i]) |
| 1521 | continue; |
| 1522 | index = -1; |
| 1523 | for (j = 0; j < spec->num_muxes; j++) { |
| 1524 | int num_cons; |
| 1525 | num_cons = snd_hda_get_connections(codec, |
| 1526 | spec->mux_nids[j], |
| 1527 | con_lst, |
| 1528 | HDA_MAX_NUM_INPUTS); |
| 1529 | for (k = 0; k < num_cons; k++) |
| 1530 | if (con_lst[k] == cfg->input_pins[i]) { |
| 1531 | index = k; |
| 1532 | goto found; |
| 1533 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1534 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1535 | continue; |
| 1536 | found: |
| 1537 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 1538 | imux->items[imux->num_items].index = index; |
| 1539 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1540 | } |
| 1541 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1542 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1543 | /* |
| 1544 | * Set the current input for the muxes. |
| 1545 | * The STAC9221 has two input muxes with identical source |
| 1546 | * NID lists. Hopefully this won't get confused. |
| 1547 | */ |
| 1548 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1549 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 1550 | AC_VERB_SET_CONNECT_SEL, |
| 1551 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1552 | } |
| 1553 | } |
| 1554 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1555 | return 0; |
| 1556 | } |
| 1557 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1558 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 1559 | { |
| 1560 | struct sigmatel_spec *spec = codec->spec; |
| 1561 | int i; |
| 1562 | |
| 1563 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 1564 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 1565 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 1570 | { |
| 1571 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1572 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1573 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1574 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 1575 | hda_nid_t pin; |
| 1576 | pin = spec->autocfg.hp_pins[i]; |
| 1577 | if (pin) /* connect to front */ |
| 1578 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 1579 | } |
| 1580 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 1581 | hda_nid_t pin; |
| 1582 | pin = spec->autocfg.speaker_pins[i]; |
| 1583 | if (pin) /* connect to front */ |
| 1584 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 1585 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1586 | } |
| 1587 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1588 | static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1589 | { |
| 1590 | struct sigmatel_spec *spec = codec->spec; |
| 1591 | int err; |
| 1592 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1593 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 1594 | &spec->autocfg, |
| 1595 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1596 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1597 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1598 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1599 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1600 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 1601 | return err; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1602 | if (spec->multiout.num_dacs == 0) |
| 1603 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 1604 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1605 | |
| 1606 | if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 1607 | (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || |
| 1608 | (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 1609 | return err; |
| 1610 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1611 | if (spec->num_dmics > 0) |
| 1612 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 1613 | &spec->autocfg)) < 0) |
| 1614 | return err; |
| 1615 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1616 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1617 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1618 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1619 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1620 | if (spec->autocfg.dig_out_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1621 | spec->multiout.dig_out_nid = dig_out; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1622 | if (spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1623 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1624 | |
| 1625 | if (spec->kctl_alloc) |
| 1626 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 1627 | |
| 1628 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1629 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1630 | |
| 1631 | return 1; |
| 1632 | } |
| 1633 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1634 | /* add playback controls for HP output */ |
| 1635 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 1636 | struct auto_pin_cfg *cfg) |
| 1637 | { |
| 1638 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1639 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1640 | unsigned int wid_caps; |
| 1641 | |
| 1642 | if (! pin) |
| 1643 | return 0; |
| 1644 | |
| 1645 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1646 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1647 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1648 | |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 1652 | /* add playback controls for LFE output */ |
| 1653 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 1654 | struct auto_pin_cfg *cfg) |
| 1655 | { |
| 1656 | struct sigmatel_spec *spec = codec->spec; |
| 1657 | int err; |
| 1658 | hda_nid_t lfe_pin = 0x0; |
| 1659 | int i; |
| 1660 | |
| 1661 | /* |
| 1662 | * search speaker outs and line outs for a mono speaker pin |
| 1663 | * with an amp. If one is found, add LFE controls |
| 1664 | * for it. |
| 1665 | */ |
| 1666 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 1667 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
| 1668 | unsigned long wcaps = get_wcaps(codec, pin); |
| 1669 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 1670 | if (wcaps == AC_WCAP_OUT_AMP) |
| 1671 | /* found a mono speaker with an amp, must be lfe */ |
| 1672 | lfe_pin = pin; |
| 1673 | } |
| 1674 | |
| 1675 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 1676 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 1677 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 1678 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
| 1679 | unsigned long cfg; |
| 1680 | cfg = snd_hda_codec_read(codec, pin, 0, |
| 1681 | AC_VERB_GET_CONFIG_DEFAULT, |
| 1682 | 0x00); |
| 1683 | if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) { |
| 1684 | unsigned long wcaps = get_wcaps(codec, pin); |
| 1685 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 1686 | if (wcaps == AC_WCAP_OUT_AMP) |
| 1687 | /* found a mono speaker with an amp, |
| 1688 | must be lfe */ |
| 1689 | lfe_pin = pin; |
| 1690 | } |
| 1691 | } |
| 1692 | } |
| 1693 | |
| 1694 | if (lfe_pin) { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1695 | err = create_controls(spec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 1696 | if (err < 0) |
| 1697 | return err; |
| 1698 | } |
| 1699 | |
| 1700 | return 0; |
| 1701 | } |
| 1702 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1703 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 1704 | { |
| 1705 | struct sigmatel_spec *spec = codec->spec; |
| 1706 | int err; |
| 1707 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1708 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1709 | return err; |
| 1710 | |
| 1711 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 1712 | return err; |
| 1713 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1714 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 1715 | return err; |
| 1716 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 1717 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 1718 | return err; |
| 1719 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1720 | if (spec->autocfg.dig_out_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1721 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1722 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1723 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1724 | |
| 1725 | if (spec->kctl_alloc) |
| 1726 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 1727 | |
| 1728 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1729 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1730 | |
| 1731 | return 1; |
| 1732 | } |
| 1733 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1734 | /* |
| 1735 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 1736 | * funky external mute control using GPIO pins. |
| 1737 | */ |
| 1738 | |
| 1739 | static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 1740 | { |
| 1741 | unsigned int gpiostate, gpiomask, gpiodir; |
| 1742 | |
| 1743 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 1744 | AC_VERB_GET_GPIO_DATA, 0); |
| 1745 | |
| 1746 | if (!muted) |
| 1747 | gpiostate |= (1 << pin); |
| 1748 | else |
| 1749 | gpiostate &= ~(1 << pin); |
| 1750 | |
| 1751 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 1752 | AC_VERB_GET_GPIO_MASK, 0); |
| 1753 | gpiomask |= (1 << pin); |
| 1754 | |
| 1755 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 1756 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 1757 | gpiodir |= (1 << pin); |
| 1758 | |
| 1759 | /* AppleHDA seems to do this -- WTF is this verb?? */ |
| 1760 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 1761 | |
| 1762 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1763 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 1764 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1765 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 1766 | |
| 1767 | msleep(1); |
| 1768 | |
| 1769 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1770 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 1771 | } |
| 1772 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1773 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 1774 | unsigned int event) |
| 1775 | { |
| 1776 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) |
| 1777 | snd_hda_codec_write(codec, nid, 0, |
| 1778 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 1779 | (AC_USRSP_EN | event)); |
| 1780 | } |
| 1781 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1782 | static int stac92xx_init(struct hda_codec *codec) |
| 1783 | { |
| 1784 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1785 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1786 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1787 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1788 | snd_hda_sequence_write(codec, spec->init); |
| 1789 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1790 | /* set up pins */ |
| 1791 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1792 | /* Enable unsolicited responses on the HP widget */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1793 | for (i = 0; i < cfg->hp_outs; i++) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1794 | enable_pin_detect(codec, cfg->hp_pins[i], |
| 1795 | STAC_HP_EVENT); |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 1796 | /* force to enable the first line-out; the others are set up |
| 1797 | * in unsol_event |
| 1798 | */ |
| 1799 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
| 1800 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb995a8 | 2006-09-21 14:28:21 +0200 | [diff] [blame] | 1801 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1802 | /* fake event to set up pins */ |
| 1803 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 1804 | } else { |
| 1805 | stac92xx_auto_init_multi_out(codec); |
| 1806 | stac92xx_auto_init_hp_out(codec); |
| 1807 | } |
| 1808 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1809 | hda_nid_t nid = cfg->input_pins[i]; |
| 1810 | if (nid) { |
| 1811 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 1812 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) |
| 1813 | pinctl |= stac92xx_get_vref(codec, nid); |
| 1814 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 1815 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1816 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1817 | if (spec->num_dmics > 0) |
| 1818 | for (i = 0; i < spec->num_dmics; i++) |
| 1819 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 1820 | AC_PINCTL_IN_EN); |
| 1821 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1822 | if (cfg->dig_out_pin) |
| 1823 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, |
| 1824 | AC_PINCTL_OUT_EN); |
| 1825 | if (cfg->dig_in_pin) |
| 1826 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 1827 | AC_PINCTL_IN_EN); |
| 1828 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1829 | if (spec->gpio_mute) { |
| 1830 | stac922x_gpio_mute(codec, 0, 0); |
| 1831 | stac922x_gpio_mute(codec, 1, 0); |
| 1832 | } |
| 1833 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1834 | return 0; |
| 1835 | } |
| 1836 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1837 | static void stac92xx_free(struct hda_codec *codec) |
| 1838 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1839 | struct sigmatel_spec *spec = codec->spec; |
| 1840 | int i; |
| 1841 | |
| 1842 | if (! spec) |
| 1843 | return; |
| 1844 | |
| 1845 | if (spec->kctl_alloc) { |
| 1846 | for (i = 0; i < spec->num_kctl_used; i++) |
| 1847 | kfree(spec->kctl_alloc[i].name); |
| 1848 | kfree(spec->kctl_alloc); |
| 1849 | } |
| 1850 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1851 | if (spec->bios_pin_configs) |
| 1852 | kfree(spec->bios_pin_configs); |
| 1853 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1854 | kfree(spec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1855 | } |
| 1856 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1857 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 1858 | unsigned int flag) |
| 1859 | { |
| 1860 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 1861 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1862 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 1863 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 1864 | /* |
| 1865 | * we need to check the current set-up direction of |
| 1866 | * shared input pins since they can be switched via |
| 1867 | * "xxx as Output" mixer switch |
| 1868 | */ |
| 1869 | struct sigmatel_spec *spec = codec->spec; |
| 1870 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1871 | if ((nid == cfg->input_pins[AUTO_PIN_LINE] && |
| 1872 | spec->line_switch) || |
| 1873 | (nid == cfg->input_pins[AUTO_PIN_MIC] && |
| 1874 | spec->mic_switch)) |
| 1875 | return; |
| 1876 | } |
| 1877 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1878 | /* if setting pin direction bits, clear the current |
| 1879 | direction bits first */ |
| 1880 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 1881 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 1882 | |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1883 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1884 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1885 | pin_ctl | flag); |
| 1886 | } |
| 1887 | |
| 1888 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 1889 | unsigned int flag) |
| 1890 | { |
| 1891 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 1892 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1893 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1894 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1895 | pin_ctl & ~flag); |
| 1896 | } |
| 1897 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1898 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
| 1899 | { |
| 1900 | if (!nid) |
| 1901 | return 0; |
| 1902 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) |
| 1903 | & (1 << 31)) |
| 1904 | return 1; |
| 1905 | return 0; |
| 1906 | } |
| 1907 | |
| 1908 | static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1909 | { |
| 1910 | struct sigmatel_spec *spec = codec->spec; |
| 1911 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1912 | int i, presence; |
| 1913 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1914 | presence = 0; |
| 1915 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1916 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 1917 | if (presence) |
| 1918 | break; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1919 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1920 | |
| 1921 | if (presence) { |
| 1922 | /* disable lineouts, enable hp */ |
| 1923 | for (i = 0; i < cfg->line_outs; i++) |
| 1924 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 1925 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1926 | for (i = 0; i < cfg->speaker_outs; i++) |
| 1927 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 1928 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1929 | } else { |
| 1930 | /* enable lineouts, disable hp */ |
| 1931 | for (i = 0; i < cfg->line_outs; i++) |
| 1932 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 1933 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1934 | for (i = 0; i < cfg->speaker_outs; i++) |
| 1935 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 1936 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1937 | } |
| 1938 | } |
| 1939 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1940 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1941 | { |
| 1942 | switch (res >> 26) { |
| 1943 | case STAC_HP_EVENT: |
| 1944 | stac92xx_hp_detect(codec, res); |
| 1945 | break; |
| 1946 | } |
| 1947 | } |
| 1948 | |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1949 | #ifdef CONFIG_PM |
| 1950 | static int stac92xx_resume(struct hda_codec *codec) |
| 1951 | { |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1952 | stac92xx_set_config_regs(codec); |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 1953 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1954 | snd_hda_codec_resume_amp(codec); |
| 1955 | snd_hda_codec_resume_cache(codec); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1956 | return 0; |
| 1957 | } |
| 1958 | #endif |
| 1959 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1960 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 1961 | .build_controls = stac92xx_build_controls, |
| 1962 | .build_pcms = stac92xx_build_pcms, |
| 1963 | .init = stac92xx_init, |
| 1964 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1965 | .unsol_event = stac92xx_unsol_event, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1966 | #ifdef CONFIG_PM |
| 1967 | .resume = stac92xx_resume, |
| 1968 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1969 | }; |
| 1970 | |
| 1971 | static int patch_stac9200(struct hda_codec *codec) |
| 1972 | { |
| 1973 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1974 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1975 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1976 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1977 | if (spec == NULL) |
| 1978 | return -ENOMEM; |
| 1979 | |
| 1980 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 1981 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1982 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1983 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 1984 | stac9200_models, |
| 1985 | stac9200_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1986 | if (spec->board_config < 0) { |
| 1987 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 1988 | err = stac92xx_save_bios_config_regs(codec); |
| 1989 | if (err < 0) { |
| 1990 | stac92xx_free(codec); |
| 1991 | return err; |
| 1992 | } |
| 1993 | spec->pin_configs = spec->bios_pin_configs; |
| 1994 | } else { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1995 | spec->pin_configs = stac9200_brd_tbl[spec->board_config]; |
| 1996 | stac92xx_set_config_regs(codec); |
| 1997 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1998 | |
| 1999 | spec->multiout.max_channels = 2; |
| 2000 | spec->multiout.num_dacs = 1; |
| 2001 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 2002 | spec->adc_nids = stac9200_adc_nids; |
| 2003 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2004 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2005 | spec->num_dmics = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2006 | |
| 2007 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2008 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2009 | |
| 2010 | err = stac9200_parse_auto_config(codec); |
| 2011 | if (err < 0) { |
| 2012 | stac92xx_free(codec); |
| 2013 | return err; |
| 2014 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2015 | |
| 2016 | codec->patch_ops = stac92xx_patch_ops; |
| 2017 | |
| 2018 | return 0; |
| 2019 | } |
| 2020 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2021 | static int patch_stac925x(struct hda_codec *codec) |
| 2022 | { |
| 2023 | struct sigmatel_spec *spec; |
| 2024 | int err; |
| 2025 | |
| 2026 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2027 | if (spec == NULL) |
| 2028 | return -ENOMEM; |
| 2029 | |
| 2030 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 2031 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2032 | spec->pin_nids = stac925x_pin_nids; |
| 2033 | spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, |
| 2034 | stac925x_models, |
| 2035 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2036 | again: |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2037 | if (spec->board_config < 0) { |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 2038 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
| 2039 | "using BIOS defaults\n"); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2040 | err = stac92xx_save_bios_config_regs(codec); |
| 2041 | if (err < 0) { |
| 2042 | stac92xx_free(codec); |
| 2043 | return err; |
| 2044 | } |
| 2045 | spec->pin_configs = spec->bios_pin_configs; |
| 2046 | } else if (stac925x_brd_tbl[spec->board_config] != NULL){ |
| 2047 | spec->pin_configs = stac925x_brd_tbl[spec->board_config]; |
| 2048 | stac92xx_set_config_regs(codec); |
| 2049 | } |
| 2050 | |
| 2051 | spec->multiout.max_channels = 2; |
| 2052 | spec->multiout.num_dacs = 1; |
| 2053 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 2054 | spec->adc_nids = stac925x_adc_nids; |
| 2055 | spec->mux_nids = stac925x_mux_nids; |
| 2056 | spec->num_muxes = 1; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 2057 | switch (codec->vendor_id) { |
| 2058 | case 0x83847632: /* STAC9202 */ |
| 2059 | case 0x83847633: /* STAC9202D */ |
| 2060 | case 0x83847636: /* STAC9251 */ |
| 2061 | case 0x83847637: /* STAC9251D */ |
| 2062 | spec->num_dmics = 1; |
| 2063 | spec->dmic_nids = stac925x_dmic_nids; |
| 2064 | break; |
| 2065 | default: |
| 2066 | spec->num_dmics = 0; |
| 2067 | break; |
| 2068 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2069 | |
| 2070 | spec->init = stac925x_core_init; |
| 2071 | spec->mixer = stac925x_mixer; |
| 2072 | |
| 2073 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2074 | if (!err) { |
| 2075 | if (spec->board_config < 0) { |
| 2076 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2077 | "available, default to model=ref\n"); |
| 2078 | spec->board_config = STAC_925x_REF; |
| 2079 | goto again; |
| 2080 | } |
| 2081 | err = -EINVAL; |
| 2082 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2083 | if (err < 0) { |
| 2084 | stac92xx_free(codec); |
| 2085 | return err; |
| 2086 | } |
| 2087 | |
| 2088 | codec->patch_ops = stac92xx_patch_ops; |
| 2089 | |
| 2090 | return 0; |
| 2091 | } |
| 2092 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2093 | static int patch_stac922x(struct hda_codec *codec) |
| 2094 | { |
| 2095 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2096 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2097 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 2098 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2099 | if (spec == NULL) |
| 2100 | return -ENOMEM; |
| 2101 | |
| 2102 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 2103 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2104 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2105 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 2106 | stac922x_models, |
| 2107 | stac922x_cfg_tbl); |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2108 | if (spec->board_config == STAC_INTEL_MAC_V3) { |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2109 | spec->gpio_mute = 1; |
| 2110 | /* Intel Macs have all same PCI SSID, so we need to check |
| 2111 | * codec SSID to distinguish the exact models |
| 2112 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2113 | printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2114 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2115 | |
| 2116 | case 0x106b0800: |
| 2117 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 2118 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2119 | case 0x106b0600: |
| 2120 | case 0x106b0700: |
| 2121 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2122 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2123 | case 0x106b0e00: |
| 2124 | case 0x106b0f00: |
| 2125 | case 0x106b1600: |
| 2126 | case 0x106b1700: |
| 2127 | case 0x106b0200: |
| 2128 | case 0x106b1e00: |
| 2129 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2130 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2131 | case 0x106b1a00: |
| 2132 | case 0x00000100: |
| 2133 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2134 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2135 | case 0x106b0a00: |
| 2136 | case 0x106b2200: |
| 2137 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2138 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2139 | } |
| 2140 | } |
| 2141 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2142 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2143 | if (spec->board_config < 0) { |
| 2144 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 2145 | "using BIOS defaults\n"); |
| 2146 | err = stac92xx_save_bios_config_regs(codec); |
| 2147 | if (err < 0) { |
| 2148 | stac92xx_free(codec); |
| 2149 | return err; |
| 2150 | } |
| 2151 | spec->pin_configs = spec->bios_pin_configs; |
| 2152 | } else if (stac922x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2153 | spec->pin_configs = stac922x_brd_tbl[spec->board_config]; |
| 2154 | stac92xx_set_config_regs(codec); |
| 2155 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2156 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2157 | spec->adc_nids = stac922x_adc_nids; |
| 2158 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2159 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2160 | spec->num_dmics = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2161 | |
| 2162 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2163 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2164 | |
| 2165 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2166 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2167 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2168 | if (!err) { |
| 2169 | if (spec->board_config < 0) { |
| 2170 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2171 | "available, default to model=ref\n"); |
| 2172 | spec->board_config = STAC_D945_REF; |
| 2173 | goto again; |
| 2174 | } |
| 2175 | err = -EINVAL; |
| 2176 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2177 | if (err < 0) { |
| 2178 | stac92xx_free(codec); |
| 2179 | return err; |
| 2180 | } |
| 2181 | |
| 2182 | codec->patch_ops = stac92xx_patch_ops; |
| 2183 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 2184 | /* Fix Mux capture level; max to 2 */ |
| 2185 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 2186 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 2187 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 2188 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 2189 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 2190 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2191 | return 0; |
| 2192 | } |
| 2193 | |
| 2194 | static int patch_stac927x(struct hda_codec *codec) |
| 2195 | { |
| 2196 | struct sigmatel_spec *spec; |
| 2197 | int err; |
| 2198 | |
| 2199 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2200 | if (spec == NULL) |
| 2201 | return -ENOMEM; |
| 2202 | |
| 2203 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 2204 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2205 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2206 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 2207 | stac927x_models, |
| 2208 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2209 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2210 | if (spec->board_config < 0) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2211 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n"); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2212 | err = stac92xx_save_bios_config_regs(codec); |
| 2213 | if (err < 0) { |
| 2214 | stac92xx_free(codec); |
| 2215 | return err; |
| 2216 | } |
| 2217 | spec->pin_configs = spec->bios_pin_configs; |
| 2218 | } else if (stac927x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2219 | spec->pin_configs = stac927x_brd_tbl[spec->board_config]; |
| 2220 | stac92xx_set_config_regs(codec); |
| 2221 | } |
| 2222 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2223 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2224 | case STAC_D965_3ST: |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2225 | spec->adc_nids = stac927x_adc_nids; |
| 2226 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2227 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2228 | spec->num_dmics = 0; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2229 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2230 | spec->mixer = stac9227_mixer; |
| 2231 | break; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2232 | case STAC_D965_5ST: |
| 2233 | spec->adc_nids = stac927x_adc_nids; |
| 2234 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2235 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2236 | spec->num_dmics = 0; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2237 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2238 | spec->mixer = stac9227_mixer; |
| 2239 | break; |
| 2240 | default: |
| 2241 | spec->adc_nids = stac927x_adc_nids; |
| 2242 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2243 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2244 | spec->num_dmics = 0; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2245 | spec->init = stac927x_core_init; |
| 2246 | spec->mixer = stac927x_mixer; |
| 2247 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2248 | |
| 2249 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2250 | /* GPIO0 High = Enable EAPD */ |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 2251 | spec->gpio_mask = spec->gpio_data = 0x00000001; |
| 2252 | stac92xx_enable_gpio_mask(codec); |
Matthew Ranostay | 92a22be | 2007-06-19 16:48:28 +0200 | [diff] [blame] | 2253 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2254 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2255 | if (!err) { |
| 2256 | if (spec->board_config < 0) { |
| 2257 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2258 | "available, default to model=ref\n"); |
| 2259 | spec->board_config = STAC_D965_REF; |
| 2260 | goto again; |
| 2261 | } |
| 2262 | err = -EINVAL; |
| 2263 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2264 | if (err < 0) { |
| 2265 | stac92xx_free(codec); |
| 2266 | return err; |
| 2267 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2268 | |
| 2269 | codec->patch_ops = stac92xx_patch_ops; |
| 2270 | |
| 2271 | return 0; |
| 2272 | } |
| 2273 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2274 | static int patch_stac9205(struct hda_codec *codec) |
| 2275 | { |
| 2276 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 2277 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2278 | |
| 2279 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2280 | if (spec == NULL) |
| 2281 | return -ENOMEM; |
| 2282 | |
| 2283 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 2284 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2285 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2286 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 2287 | stac9205_models, |
| 2288 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2289 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2290 | if (spec->board_config < 0) { |
| 2291 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
| 2292 | err = stac92xx_save_bios_config_regs(codec); |
| 2293 | if (err < 0) { |
| 2294 | stac92xx_free(codec); |
| 2295 | return err; |
| 2296 | } |
| 2297 | spec->pin_configs = spec->bios_pin_configs; |
| 2298 | } else { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2299 | spec->pin_configs = stac9205_brd_tbl[spec->board_config]; |
| 2300 | stac92xx_set_config_regs(codec); |
| 2301 | } |
| 2302 | |
| 2303 | spec->adc_nids = stac9205_adc_nids; |
| 2304 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2305 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2306 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2307 | spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2308 | spec->dmux_nid = 0x1d; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2309 | |
| 2310 | spec->init = stac9205_core_init; |
| 2311 | spec->mixer = stac9205_mixer; |
| 2312 | |
| 2313 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2314 | |
| 2315 | if (spec->board_config == STAC_M43xx) { |
| 2316 | /* Enable SPDIF in/out */ |
| 2317 | stac92xx_set_config_reg(codec, 0x1f, 0x01441030); |
| 2318 | stac92xx_set_config_reg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 2319 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 2320 | spec->gpio_mask = 0x00000007; /* GPIO0-2 */ |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2321 | /* GPIO0 High = EAPD, GPIO1 Low = DRM, |
| 2322 | * GPIO2 High = Headphone Mute |
| 2323 | */ |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 2324 | spec->gpio_data = 0x00000005; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2325 | } else |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 2326 | spec->gpio_mask = spec->gpio_data = |
| 2327 | 0x00000001; /* GPIO0 High = EAPD */ |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2328 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 2329 | stac92xx_enable_gpio_mask(codec); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2330 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2331 | if (!err) { |
| 2332 | if (spec->board_config < 0) { |
| 2333 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2334 | "available, default to model=ref\n"); |
| 2335 | spec->board_config = STAC_9205_REF; |
| 2336 | goto again; |
| 2337 | } |
| 2338 | err = -EINVAL; |
| 2339 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2340 | if (err < 0) { |
| 2341 | stac92xx_free(codec); |
| 2342 | return err; |
| 2343 | } |
| 2344 | |
| 2345 | codec->patch_ops = stac92xx_patch_ops; |
| 2346 | |
| 2347 | return 0; |
| 2348 | } |
| 2349 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2350 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2351 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2352 | */ |
| 2353 | |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 2354 | /* static config for Sony VAIO FE550G and Sony VAIO AR */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2355 | static hda_nid_t vaio_dacs[] = { 0x2 }; |
| 2356 | #define VAIO_HP_DAC 0x5 |
| 2357 | static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; |
| 2358 | static hda_nid_t vaio_mux_nids[] = { 0x15 }; |
| 2359 | |
| 2360 | static struct hda_input_mux vaio_mux = { |
| 2361 | .num_items = 2, |
| 2362 | .items = { |
Takashi Iwai | d773781 | 2006-04-25 13:05:43 +0200 | [diff] [blame] | 2363 | /* { "HP", 0x0 }, */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 2364 | { "Mic Jack", 0x1 }, |
| 2365 | { "Internal Mic", 0x2 }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2366 | { "PCM", 0x3 }, |
| 2367 | } |
| 2368 | }; |
| 2369 | |
| 2370 | static struct hda_verb vaio_init[] = { |
| 2371 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 2372 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 2373 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 2374 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 2375 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 2376 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2377 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 2378 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 2379 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 2380 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 2381 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 2382 | {} |
| 2383 | }; |
| 2384 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2385 | static struct hda_verb vaio_ar_init[] = { |
| 2386 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 2387 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 2388 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 2389 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 2390 | /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ |
| 2391 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 2392 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2393 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 2394 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 2395 | /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ |
| 2396 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 2397 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 2398 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 2399 | {} |
| 2400 | }; |
| 2401 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2402 | /* bind volumes of both NID 0x02 and 0x05 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame^] | 2403 | static struct hda_bind_ctls vaio_bind_master_vol = { |
| 2404 | .ops = &snd_hda_bind_vol, |
| 2405 | .values = { |
| 2406 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 2407 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 2408 | 0 |
| 2409 | }, |
| 2410 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2411 | |
| 2412 | /* bind volumes of both NID 0x02 and 0x05 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame^] | 2413 | static struct hda_bind_ctls vaio_bind_master_sw = { |
| 2414 | .ops = &snd_hda_bind_sw, |
| 2415 | .values = { |
| 2416 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 2417 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 2418 | 0, |
| 2419 | }, |
| 2420 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2421 | |
| 2422 | static struct snd_kcontrol_new vaio_mixer[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame^] | 2423 | HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), |
| 2424 | HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2425 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 2426 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 2427 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 2428 | { |
| 2429 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2430 | .name = "Capture Source", |
| 2431 | .count = 1, |
| 2432 | .info = stac92xx_mux_enum_info, |
| 2433 | .get = stac92xx_mux_enum_get, |
| 2434 | .put = stac92xx_mux_enum_put, |
| 2435 | }, |
| 2436 | {} |
| 2437 | }; |
| 2438 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2439 | static struct snd_kcontrol_new vaio_ar_mixer[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame^] | 2440 | HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), |
| 2441 | HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2442 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 2443 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 2444 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 2445 | /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT), |
| 2446 | HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/ |
| 2447 | { |
| 2448 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2449 | .name = "Capture Source", |
| 2450 | .count = 1, |
| 2451 | .info = stac92xx_mux_enum_info, |
| 2452 | .get = stac92xx_mux_enum_get, |
| 2453 | .put = stac92xx_mux_enum_put, |
| 2454 | }, |
| 2455 | {} |
| 2456 | }; |
| 2457 | |
| 2458 | static struct hda_codec_ops stac9872_patch_ops = { |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2459 | .build_controls = stac92xx_build_controls, |
| 2460 | .build_pcms = stac92xx_build_pcms, |
| 2461 | .init = stac92xx_init, |
| 2462 | .free = stac92xx_free, |
| 2463 | #ifdef CONFIG_PM |
| 2464 | .resume = stac92xx_resume, |
| 2465 | #endif |
| 2466 | }; |
| 2467 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2468 | enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ |
| 2469 | CXD9872RD_VAIO, |
| 2470 | /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ |
| 2471 | STAC9872AK_VAIO, |
| 2472 | /* Unknown. id=0x83847661 and subsys=0x104D1200. */ |
| 2473 | STAC9872K_VAIO, |
| 2474 | /* AR Series. id=0x83847664 and subsys=104D1300 */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2475 | CXD9872AKD_VAIO, |
| 2476 | STAC_9872_MODELS, |
| 2477 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2478 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2479 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 2480 | [CXD9872RD_VAIO] = "vaio", |
| 2481 | [CXD9872AKD_VAIO] = "vaio-ar", |
| 2482 | }; |
| 2483 | |
| 2484 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 2485 | SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 2486 | SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 2487 | SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), |
Tobin Davis | 68e2254 | 2007-03-12 11:36:39 +0100 | [diff] [blame] | 2488 | SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2489 | {} |
| 2490 | }; |
| 2491 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2492 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2493 | { |
| 2494 | struct sigmatel_spec *spec; |
| 2495 | int board_config; |
| 2496 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2497 | board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 2498 | stac9872_models, |
| 2499 | stac9872_cfg_tbl); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2500 | if (board_config < 0) |
| 2501 | /* unknown config, let generic-parser do its job... */ |
| 2502 | return snd_hda_parse_generic_codec(codec); |
| 2503 | |
| 2504 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2505 | if (spec == NULL) |
| 2506 | return -ENOMEM; |
| 2507 | |
| 2508 | codec->spec = spec; |
| 2509 | switch (board_config) { |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2510 | case CXD9872RD_VAIO: |
| 2511 | case STAC9872AK_VAIO: |
| 2512 | case STAC9872K_VAIO: |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2513 | spec->mixer = vaio_mixer; |
| 2514 | spec->init = vaio_init; |
| 2515 | spec->multiout.max_channels = 2; |
| 2516 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 2517 | spec->multiout.dac_nids = vaio_dacs; |
| 2518 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 2519 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 2520 | spec->adc_nids = vaio_adcs; |
| 2521 | spec->input_mux = &vaio_mux; |
| 2522 | spec->mux_nids = vaio_mux_nids; |
| 2523 | break; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2524 | |
| 2525 | case CXD9872AKD_VAIO: |
| 2526 | spec->mixer = vaio_ar_mixer; |
| 2527 | spec->init = vaio_ar_init; |
| 2528 | spec->multiout.max_channels = 2; |
| 2529 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 2530 | spec->multiout.dac_nids = vaio_dacs; |
| 2531 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 2532 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 2533 | spec->adc_nids = vaio_adcs; |
| 2534 | spec->input_mux = &vaio_mux; |
| 2535 | spec->mux_nids = vaio_mux_nids; |
| 2536 | break; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2537 | } |
| 2538 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2539 | codec->patch_ops = stac9872_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2540 | return 0; |
| 2541 | } |
| 2542 | |
| 2543 | |
| 2544 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2545 | * patch entries |
| 2546 | */ |
| 2547 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
| 2548 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 2549 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 2550 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 2551 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 2552 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 2553 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 2554 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 2555 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 2556 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 2557 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 2558 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 2559 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 2560 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2561 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 2562 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 2563 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 2564 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 2565 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 2566 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 2567 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 2568 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 2569 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 2570 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2571 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 2572 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 2573 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 2574 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 2575 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 2576 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2577 | /* The following does not take into account .id=0x83847661 when subsys = |
| 2578 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 2579 | * currently not fully supported. |
| 2580 | */ |
| 2581 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 2582 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 2583 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2584 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 2585 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 2586 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 2587 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 2588 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 2589 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 2590 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 2591 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2592 | {} /* terminator */ |
| 2593 | }; |