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