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 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 817 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 818 | struct hda_codec *codec, |
| 819 | unsigned int stream_tag, |
| 820 | unsigned int format, |
| 821 | struct snd_pcm_substream *substream) |
| 822 | { |
| 823 | struct sigmatel_spec *spec = codec->spec; |
| 824 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 825 | stream_tag, format, substream); |
| 826 | } |
| 827 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 828 | |
| 829 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 830 | * Analog capture callbacks |
| 831 | */ |
| 832 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 833 | struct hda_codec *codec, |
| 834 | unsigned int stream_tag, |
| 835 | unsigned int format, |
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], |
| 841 | stream_tag, 0, format); |
| 842 | return 0; |
| 843 | } |
| 844 | |
| 845 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 846 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 847 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 848 | { |
| 849 | struct sigmatel_spec *spec = codec->spec; |
| 850 | |
| 851 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 852 | return 0; |
| 853 | } |
| 854 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 855 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 856 | .substreams = 1, |
| 857 | .channels_min = 2, |
| 858 | .channels_max = 2, |
| 859 | /* NID is set in stac92xx_build_pcms */ |
| 860 | .ops = { |
| 861 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 862 | .close = stac92xx_dig_playback_pcm_close, |
| 863 | .prepare = stac92xx_dig_playback_pcm_prepare |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 864 | }, |
| 865 | }; |
| 866 | |
| 867 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 868 | .substreams = 1, |
| 869 | .channels_min = 2, |
| 870 | .channels_max = 2, |
| 871 | /* NID is set in stac92xx_build_pcms */ |
| 872 | }; |
| 873 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 874 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 875 | .substreams = 1, |
| 876 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 877 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 878 | .nid = 0x02, /* 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 Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 886 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 887 | .substreams = 1, |
| 888 | .channels_min = 2, |
| 889 | .channels_max = 2, |
| 890 | .nid = 0x06, /* NID to query formats and rates */ |
| 891 | .ops = { |
| 892 | .open = stac92xx_playback_pcm_open, |
| 893 | .prepare = stac92xx_playback_pcm_prepare, |
| 894 | .cleanup = stac92xx_playback_pcm_cleanup |
| 895 | }, |
| 896 | }; |
| 897 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 898 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
| 899 | .substreams = 2, |
| 900 | .channels_min = 2, |
| 901 | .channels_max = 2, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 902 | /* NID is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 903 | .ops = { |
| 904 | .prepare = stac92xx_capture_pcm_prepare, |
| 905 | .cleanup = stac92xx_capture_pcm_cleanup |
| 906 | }, |
| 907 | }; |
| 908 | |
| 909 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 910 | { |
| 911 | struct sigmatel_spec *spec = codec->spec; |
| 912 | struct hda_pcm *info = spec->pcm_rec; |
| 913 | |
| 914 | codec->num_pcms = 1; |
| 915 | codec->pcm_info = info; |
| 916 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 917 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 918 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 919 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 920 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 921 | |
| 922 | if (spec->alt_switch) { |
| 923 | codec->num_pcms++; |
| 924 | info++; |
| 925 | info->name = "STAC92xx Analog Alt"; |
| 926 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 927 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 928 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 929 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 930 | codec->num_pcms++; |
| 931 | info++; |
| 932 | info->name = "STAC92xx Digital"; |
| 933 | if (spec->multiout.dig_out_nid) { |
| 934 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 935 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 936 | } |
| 937 | if (spec->dig_in_nid) { |
| 938 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 939 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 940 | } |
| 941 | } |
| 942 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 943 | return 0; |
| 944 | } |
| 945 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 946 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 947 | { |
| 948 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 949 | AC_PAR_PIN_CAP); |
| 950 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 951 | if (pincap & AC_PINCAP_VREF_100) |
| 952 | return AC_PINCTL_VREF_100; |
| 953 | if (pincap & AC_PINCAP_VREF_80) |
| 954 | return AC_PINCTL_VREF_80; |
| 955 | if (pincap & AC_PINCAP_VREF_50) |
| 956 | return AC_PINCTL_VREF_50; |
| 957 | if (pincap & AC_PINCAP_VREF_GRD) |
| 958 | return AC_PINCTL_VREF_GRD; |
| 959 | return 0; |
| 960 | } |
| 961 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 962 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 963 | |
| 964 | { |
| 965 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 966 | } |
| 967 | |
| 968 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 969 | { |
| 970 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 971 | uinfo->count = 1; |
| 972 | uinfo->value.integer.min = 0; |
| 973 | uinfo->value.integer.max = 1; |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 978 | { |
| 979 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 980 | struct sigmatel_spec *spec = codec->spec; |
| 981 | int io_idx = kcontrol-> private_value & 0xff; |
| 982 | |
| 983 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 984 | return 0; |
| 985 | } |
| 986 | |
| 987 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 988 | { |
| 989 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 990 | struct sigmatel_spec *spec = codec->spec; |
| 991 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 992 | int io_idx = kcontrol-> private_value & 0xff; |
| 993 | unsigned short val = ucontrol->value.integer.value[0]; |
| 994 | |
| 995 | spec->io_switch[io_idx] = val; |
| 996 | |
| 997 | if (val) |
| 998 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 999 | else { |
| 1000 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 1001 | if (io_idx) /* set VREF for mic */ |
| 1002 | pinctl |= stac92xx_get_vref(codec, nid); |
| 1003 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 1004 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1005 | return 1; |
| 1006 | } |
| 1007 | |
| 1008 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 1009 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1010 | .name = xname, \ |
| 1011 | .index = 0, \ |
| 1012 | .info = stac92xx_io_switch_info, \ |
| 1013 | .get = stac92xx_io_switch_get, \ |
| 1014 | .put = stac92xx_io_switch_put, \ |
| 1015 | .private_value = xpval, \ |
| 1016 | } |
| 1017 | |
| 1018 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1019 | enum { |
| 1020 | STAC_CTL_WIDGET_VOL, |
| 1021 | STAC_CTL_WIDGET_MUTE, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1022 | STAC_CTL_WIDGET_IO_SWITCH, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1023 | }; |
| 1024 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1025 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1026 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 1027 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1028 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1029 | }; |
| 1030 | |
| 1031 | /* add dynamic controls */ |
| 1032 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) |
| 1033 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1034 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1035 | |
| 1036 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 1037 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 1038 | |
| 1039 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 1040 | if (! knew) |
| 1041 | return -ENOMEM; |
| 1042 | if (spec->kctl_alloc) { |
| 1043 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 1044 | kfree(spec->kctl_alloc); |
| 1045 | } |
| 1046 | spec->kctl_alloc = knew; |
| 1047 | spec->num_kctl_alloc = num; |
| 1048 | } |
| 1049 | |
| 1050 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 1051 | *knew = stac92xx_control_templates[type]; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 1052 | knew->name = kstrdup(name, GFP_KERNEL); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1053 | if (! knew->name) |
| 1054 | return -ENOMEM; |
| 1055 | knew->private_value = val; |
| 1056 | spec->num_kctl_used++; |
| 1057 | return 0; |
| 1058 | } |
| 1059 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1060 | /* flag inputs as additional dynamic lineouts */ |
| 1061 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 1062 | { |
| 1063 | struct sigmatel_spec *spec = codec->spec; |
| 1064 | |
| 1065 | switch (cfg->line_outs) { |
| 1066 | case 3: |
| 1067 | /* add line-in as side */ |
| 1068 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 1069 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; |
| 1070 | spec->line_switch = 1; |
| 1071 | cfg->line_outs++; |
| 1072 | } |
| 1073 | break; |
| 1074 | case 2: |
| 1075 | /* add line-in as clfe and mic as side */ |
| 1076 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 1077 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; |
| 1078 | spec->line_switch = 1; |
| 1079 | cfg->line_outs++; |
| 1080 | } |
| 1081 | if (cfg->input_pins[AUTO_PIN_MIC]) { |
| 1082 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; |
| 1083 | spec->mic_switch = 1; |
| 1084 | cfg->line_outs++; |
| 1085 | } |
| 1086 | break; |
| 1087 | case 1: |
| 1088 | /* add line-in as surr and mic as clfe */ |
| 1089 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 1090 | cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; |
| 1091 | spec->line_switch = 1; |
| 1092 | cfg->line_outs++; |
| 1093 | } |
| 1094 | if (cfg->input_pins[AUTO_PIN_MIC]) { |
| 1095 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; |
| 1096 | spec->mic_switch = 1; |
| 1097 | cfg->line_outs++; |
| 1098 | } |
| 1099 | break; |
| 1100 | } |
| 1101 | |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1105 | /* |
| 1106 | * XXX The line_out pin widget connection list may not be set to the |
| 1107 | * desired DAC nid. This is the case on 927x where ports A and B can |
| 1108 | * be routed to several DACs. |
| 1109 | * |
| 1110 | * This requires an analysis of the line-out/hp pin configuration |
| 1111 | * to provide a best fit for pin/DAC configurations that are routable. |
| 1112 | * For now, 927x DAC4 is not supported and 927x DAC1 output to ports |
| 1113 | * A and B is not supported. |
| 1114 | */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1115 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1116 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, |
| 1117 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1118 | { |
| 1119 | struct sigmatel_spec *spec = codec->spec; |
| 1120 | hda_nid_t nid; |
| 1121 | int i; |
| 1122 | |
| 1123 | /* check the pins hardwired to audio widget */ |
| 1124 | for (i = 0; i < cfg->line_outs; i++) { |
| 1125 | nid = cfg->line_out_pins[i]; |
| 1126 | spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, |
| 1127 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1128 | } |
| 1129 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1130 | spec->multiout.num_dacs = cfg->line_outs; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1131 | |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1135 | /* create volume control/switch for the given prefx type */ |
| 1136 | static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) |
| 1137 | { |
| 1138 | char name[32]; |
| 1139 | int err; |
| 1140 | |
| 1141 | sprintf(name, "%s Playback Volume", pfx); |
| 1142 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 1143 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 1144 | if (err < 0) |
| 1145 | return err; |
| 1146 | sprintf(name, "%s Playback Switch", pfx); |
| 1147 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 1148 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 1149 | if (err < 0) |
| 1150 | return err; |
| 1151 | return 0; |
| 1152 | } |
| 1153 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1154 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1155 | static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, |
| 1156 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1157 | { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1158 | static const char *chname[4] = { |
| 1159 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 1160 | }; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1161 | hda_nid_t nid; |
| 1162 | int i, err; |
| 1163 | |
| 1164 | for (i = 0; i < cfg->line_outs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1165 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1166 | continue; |
| 1167 | |
| 1168 | nid = spec->multiout.dac_nids[i]; |
| 1169 | |
| 1170 | if (i == 2) { |
| 1171 | /* Center/LFE */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1172 | err = create_controls(spec, "Center", nid, 1); |
| 1173 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1174 | return err; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1175 | err = create_controls(spec, "LFE", nid, 2); |
| 1176 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1177 | return err; |
| 1178 | } else { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1179 | err = create_controls(spec, chname[i], nid, 3); |
| 1180 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1181 | return err; |
| 1182 | } |
| 1183 | } |
| 1184 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1185 | if (spec->line_switch) |
| 1186 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) |
| 1187 | return err; |
| 1188 | |
| 1189 | if (spec->mic_switch) |
| 1190 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) |
| 1191 | return err; |
| 1192 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1193 | return 0; |
| 1194 | } |
| 1195 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1196 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 1197 | { |
| 1198 | int i; |
| 1199 | |
| 1200 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 1201 | if (spec->multiout.dac_nids[i] == nid) |
| 1202 | return 1; |
| 1203 | } |
| 1204 | if (spec->multiout.hp_nid == nid) |
| 1205 | return 1; |
| 1206 | return 0; |
| 1207 | } |
| 1208 | |
| 1209 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 1210 | { |
| 1211 | if (!spec->multiout.hp_nid) |
| 1212 | spec->multiout.hp_nid = nid; |
| 1213 | else if (spec->multiout.num_dacs > 4) { |
| 1214 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 1215 | return 1; |
| 1216 | } else { |
| 1217 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 1218 | spec->multiout.num_dacs++; |
| 1219 | } |
| 1220 | return 0; |
| 1221 | } |
| 1222 | |
| 1223 | /* add playback controls for Speaker and HP outputs */ |
| 1224 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 1225 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1226 | { |
| 1227 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1228 | hda_nid_t nid; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1229 | int i, old_num_dacs, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1230 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1231 | old_num_dacs = spec->multiout.num_dacs; |
| 1232 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1233 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
| 1234 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 1235 | spec->hp_detect = 1; |
| 1236 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 1237 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1238 | if (check_in_dac_nids(spec, nid)) |
| 1239 | nid = 0; |
| 1240 | if (! nid) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1241 | continue; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1242 | add_spec_dacs(spec, nid); |
| 1243 | } |
| 1244 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 1245 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0, |
| 1246 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1247 | if (check_in_dac_nids(spec, nid)) |
| 1248 | nid = 0; |
| 1249 | if (check_in_dac_nids(spec, nid)) |
| 1250 | nid = 0; |
| 1251 | if (! nid) |
| 1252 | continue; |
| 1253 | add_spec_dacs(spec, nid); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1254 | } |
| 1255 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1256 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { |
| 1257 | static const char *pfxs[] = { |
| 1258 | "Speaker", "External Speaker", "Speaker2", |
| 1259 | }; |
| 1260 | err = create_controls(spec, pfxs[i - old_num_dacs], |
| 1261 | spec->multiout.dac_nids[i], 3); |
| 1262 | if (err < 0) |
| 1263 | return err; |
| 1264 | } |
| 1265 | if (spec->multiout.hp_nid) { |
| 1266 | const char *pfx; |
| 1267 | if (old_num_dacs == spec->multiout.num_dacs) |
| 1268 | pfx = "Master"; |
| 1269 | else |
| 1270 | pfx = "Headphone"; |
| 1271 | err = create_controls(spec, pfx, spec->multiout.hp_nid, 3); |
| 1272 | if (err < 0) |
| 1273 | return err; |
| 1274 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1275 | |
| 1276 | return 0; |
| 1277 | } |
| 1278 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1279 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 1280 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1281 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 1282 | "Digital Mic 3", "Digital Mic 4" |
| 1283 | }; |
| 1284 | |
| 1285 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 1286 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 1287 | const struct auto_pin_cfg *cfg) |
| 1288 | { |
| 1289 | struct sigmatel_spec *spec = codec->spec; |
| 1290 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 1291 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 1292 | int i, j; |
| 1293 | |
| 1294 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 1295 | dimux->items[dimux->num_items].index = 0; |
| 1296 | dimux->num_items++; |
| 1297 | |
| 1298 | for (i = 0; i < spec->num_dmics; i++) { |
| 1299 | int index; |
| 1300 | int num_cons; |
| 1301 | unsigned int def_conf; |
| 1302 | |
| 1303 | def_conf = snd_hda_codec_read(codec, |
| 1304 | spec->dmic_nids[i], |
| 1305 | 0, |
| 1306 | AC_VERB_GET_CONFIG_DEFAULT, |
| 1307 | 0); |
| 1308 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 1309 | continue; |
| 1310 | |
| 1311 | num_cons = snd_hda_get_connections(codec, |
| 1312 | spec->dmux_nid, |
| 1313 | con_lst, |
| 1314 | HDA_MAX_NUM_INPUTS); |
| 1315 | for (j = 0; j < num_cons; j++) |
| 1316 | if (con_lst[j] == spec->dmic_nids[i]) { |
| 1317 | index = j; |
| 1318 | goto found; |
| 1319 | } |
| 1320 | continue; |
| 1321 | found: |
| 1322 | dimux->items[dimux->num_items].label = |
| 1323 | stac92xx_dmic_labels[dimux->num_items]; |
| 1324 | dimux->items[dimux->num_items].index = index; |
| 1325 | dimux->num_items++; |
| 1326 | } |
| 1327 | |
| 1328 | return 0; |
| 1329 | } |
| 1330 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1331 | /* create playback/capture controls for input pins */ |
| 1332 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 1333 | { |
| 1334 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1335 | struct hda_input_mux *imux = &spec->private_imux; |
| 1336 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 1337 | int i, j, k; |
| 1338 | |
| 1339 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1340 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1341 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1342 | if (!cfg->input_pins[i]) |
| 1343 | continue; |
| 1344 | index = -1; |
| 1345 | for (j = 0; j < spec->num_muxes; j++) { |
| 1346 | int num_cons; |
| 1347 | num_cons = snd_hda_get_connections(codec, |
| 1348 | spec->mux_nids[j], |
| 1349 | con_lst, |
| 1350 | HDA_MAX_NUM_INPUTS); |
| 1351 | for (k = 0; k < num_cons; k++) |
| 1352 | if (con_lst[k] == cfg->input_pins[i]) { |
| 1353 | index = k; |
| 1354 | goto found; |
| 1355 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1356 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1357 | continue; |
| 1358 | found: |
| 1359 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 1360 | imux->items[imux->num_items].index = index; |
| 1361 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1362 | } |
| 1363 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1364 | if (imux->num_items == 1) { |
| 1365 | /* |
| 1366 | * Set the current input for the muxes. |
| 1367 | * The STAC9221 has two input muxes with identical source |
| 1368 | * NID lists. Hopefully this won't get confused. |
| 1369 | */ |
| 1370 | for (i = 0; i < spec->num_muxes; i++) { |
| 1371 | snd_hda_codec_write(codec, spec->mux_nids[i], 0, |
| 1372 | AC_VERB_SET_CONNECT_SEL, |
| 1373 | imux->items[0].index); |
| 1374 | } |
| 1375 | } |
| 1376 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1377 | return 0; |
| 1378 | } |
| 1379 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1380 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 1381 | { |
| 1382 | struct sigmatel_spec *spec = codec->spec; |
| 1383 | int i; |
| 1384 | |
| 1385 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 1386 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 1387 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 1392 | { |
| 1393 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1394 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1395 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1396 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 1397 | hda_nid_t pin; |
| 1398 | pin = spec->autocfg.hp_pins[i]; |
| 1399 | if (pin) /* connect to front */ |
| 1400 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 1401 | } |
| 1402 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 1403 | hda_nid_t pin; |
| 1404 | pin = spec->autocfg.speaker_pins[i]; |
| 1405 | if (pin) /* connect to front */ |
| 1406 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 1407 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1408 | } |
| 1409 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1410 | 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] | 1411 | { |
| 1412 | struct sigmatel_spec *spec = codec->spec; |
| 1413 | int err; |
| 1414 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1415 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 1416 | &spec->autocfg, |
| 1417 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1418 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1419 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1420 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1421 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1422 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 1423 | return err; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1424 | if (spec->multiout.num_dacs == 0) |
| 1425 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 1426 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1427 | |
| 1428 | if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 1429 | (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || |
| 1430 | (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 1431 | return err; |
| 1432 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1433 | if (spec->num_dmics > 0) |
| 1434 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 1435 | &spec->autocfg)) < 0) |
| 1436 | return err; |
| 1437 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1438 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1439 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1440 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1441 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1442 | if (spec->autocfg.dig_out_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1443 | spec->multiout.dig_out_nid = dig_out; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1444 | if (spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1445 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1446 | |
| 1447 | if (spec->kctl_alloc) |
| 1448 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 1449 | |
| 1450 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1451 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1452 | |
| 1453 | return 1; |
| 1454 | } |
| 1455 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1456 | /* add playback controls for HP output */ |
| 1457 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 1458 | struct auto_pin_cfg *cfg) |
| 1459 | { |
| 1460 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1461 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1462 | unsigned int wid_caps; |
| 1463 | |
| 1464 | if (! pin) |
| 1465 | return 0; |
| 1466 | |
| 1467 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1468 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1469 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1470 | |
| 1471 | return 0; |
| 1472 | } |
| 1473 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 1474 | /* add playback controls for LFE output */ |
| 1475 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 1476 | struct auto_pin_cfg *cfg) |
| 1477 | { |
| 1478 | struct sigmatel_spec *spec = codec->spec; |
| 1479 | int err; |
| 1480 | hda_nid_t lfe_pin = 0x0; |
| 1481 | int i; |
| 1482 | |
| 1483 | /* |
| 1484 | * search speaker outs and line outs for a mono speaker pin |
| 1485 | * with an amp. If one is found, add LFE controls |
| 1486 | * for it. |
| 1487 | */ |
| 1488 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 1489 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
| 1490 | unsigned long wcaps = get_wcaps(codec, pin); |
| 1491 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 1492 | if (wcaps == AC_WCAP_OUT_AMP) |
| 1493 | /* found a mono speaker with an amp, must be lfe */ |
| 1494 | lfe_pin = pin; |
| 1495 | } |
| 1496 | |
| 1497 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 1498 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 1499 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 1500 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
| 1501 | unsigned long cfg; |
| 1502 | cfg = snd_hda_codec_read(codec, pin, 0, |
| 1503 | AC_VERB_GET_CONFIG_DEFAULT, |
| 1504 | 0x00); |
| 1505 | if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) { |
| 1506 | unsigned long wcaps = get_wcaps(codec, pin); |
| 1507 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 1508 | if (wcaps == AC_WCAP_OUT_AMP) |
| 1509 | /* found a mono speaker with an amp, |
| 1510 | must be lfe */ |
| 1511 | lfe_pin = pin; |
| 1512 | } |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | if (lfe_pin) { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1517 | err = create_controls(spec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 1518 | if (err < 0) |
| 1519 | return err; |
| 1520 | } |
| 1521 | |
| 1522 | return 0; |
| 1523 | } |
| 1524 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1525 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 1526 | { |
| 1527 | struct sigmatel_spec *spec = codec->spec; |
| 1528 | int err; |
| 1529 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1530 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1531 | return err; |
| 1532 | |
| 1533 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 1534 | return err; |
| 1535 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1536 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 1537 | return err; |
| 1538 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 1539 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 1540 | return err; |
| 1541 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1542 | if (spec->autocfg.dig_out_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1543 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1544 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1545 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1546 | |
| 1547 | if (spec->kctl_alloc) |
| 1548 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 1549 | |
| 1550 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1551 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1552 | |
| 1553 | return 1; |
| 1554 | } |
| 1555 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1556 | /* |
| 1557 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 1558 | * funky external mute control using GPIO pins. |
| 1559 | */ |
| 1560 | |
| 1561 | static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 1562 | { |
| 1563 | unsigned int gpiostate, gpiomask, gpiodir; |
| 1564 | |
| 1565 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 1566 | AC_VERB_GET_GPIO_DATA, 0); |
| 1567 | |
| 1568 | if (!muted) |
| 1569 | gpiostate |= (1 << pin); |
| 1570 | else |
| 1571 | gpiostate &= ~(1 << pin); |
| 1572 | |
| 1573 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 1574 | AC_VERB_GET_GPIO_MASK, 0); |
| 1575 | gpiomask |= (1 << pin); |
| 1576 | |
| 1577 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 1578 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 1579 | gpiodir |= (1 << pin); |
| 1580 | |
| 1581 | /* AppleHDA seems to do this -- WTF is this verb?? */ |
| 1582 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 1583 | |
| 1584 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1585 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 1586 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1587 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 1588 | |
| 1589 | msleep(1); |
| 1590 | |
| 1591 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1592 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 1593 | } |
| 1594 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1595 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 1596 | unsigned int event) |
| 1597 | { |
| 1598 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) |
| 1599 | snd_hda_codec_write(codec, nid, 0, |
| 1600 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 1601 | (AC_USRSP_EN | event)); |
| 1602 | } |
| 1603 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1604 | static int stac92xx_init(struct hda_codec *codec) |
| 1605 | { |
| 1606 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1607 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1608 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1609 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1610 | snd_hda_sequence_write(codec, spec->init); |
| 1611 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1612 | /* set up pins */ |
| 1613 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1614 | /* Enable unsolicited responses on the HP widget */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1615 | for (i = 0; i < cfg->hp_outs; i++) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1616 | enable_pin_detect(codec, cfg->hp_pins[i], |
| 1617 | STAC_HP_EVENT); |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 1618 | /* force to enable the first line-out; the others are set up |
| 1619 | * in unsol_event |
| 1620 | */ |
| 1621 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
| 1622 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb995a8 | 2006-09-21 14:28:21 +0200 | [diff] [blame] | 1623 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1624 | /* fake event to set up pins */ |
| 1625 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 1626 | } else { |
| 1627 | stac92xx_auto_init_multi_out(codec); |
| 1628 | stac92xx_auto_init_hp_out(codec); |
| 1629 | } |
| 1630 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1631 | hda_nid_t nid = cfg->input_pins[i]; |
| 1632 | if (nid) { |
| 1633 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 1634 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) |
| 1635 | pinctl |= stac92xx_get_vref(codec, nid); |
| 1636 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 1637 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1638 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1639 | if (spec->num_dmics > 0) |
| 1640 | for (i = 0; i < spec->num_dmics; i++) |
| 1641 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 1642 | AC_PINCTL_IN_EN); |
| 1643 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1644 | if (cfg->dig_out_pin) |
| 1645 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, |
| 1646 | AC_PINCTL_OUT_EN); |
| 1647 | if (cfg->dig_in_pin) |
| 1648 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 1649 | AC_PINCTL_IN_EN); |
| 1650 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1651 | if (spec->gpio_mute) { |
| 1652 | stac922x_gpio_mute(codec, 0, 0); |
| 1653 | stac922x_gpio_mute(codec, 1, 0); |
| 1654 | } |
| 1655 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1656 | return 0; |
| 1657 | } |
| 1658 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1659 | static void stac92xx_free(struct hda_codec *codec) |
| 1660 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1661 | struct sigmatel_spec *spec = codec->spec; |
| 1662 | int i; |
| 1663 | |
| 1664 | if (! spec) |
| 1665 | return; |
| 1666 | |
| 1667 | if (spec->kctl_alloc) { |
| 1668 | for (i = 0; i < spec->num_kctl_used; i++) |
| 1669 | kfree(spec->kctl_alloc[i].name); |
| 1670 | kfree(spec->kctl_alloc); |
| 1671 | } |
| 1672 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1673 | if (spec->bios_pin_configs) |
| 1674 | kfree(spec->bios_pin_configs); |
| 1675 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1676 | kfree(spec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1677 | } |
| 1678 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1679 | static void stac92xx_set_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); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1684 | if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN)) |
| 1685 | return; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1686 | snd_hda_codec_write(codec, nid, 0, |
| 1687 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1688 | pin_ctl | flag); |
| 1689 | } |
| 1690 | |
| 1691 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 1692 | unsigned int flag) |
| 1693 | { |
| 1694 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 1695 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
| 1696 | snd_hda_codec_write(codec, nid, 0, |
| 1697 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1698 | pin_ctl & ~flag); |
| 1699 | } |
| 1700 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1701 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
| 1702 | { |
| 1703 | if (!nid) |
| 1704 | return 0; |
| 1705 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) |
| 1706 | & (1 << 31)) |
| 1707 | return 1; |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
| 1711 | static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1712 | { |
| 1713 | struct sigmatel_spec *spec = codec->spec; |
| 1714 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1715 | int i, presence; |
| 1716 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1717 | presence = 0; |
| 1718 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1719 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 1720 | if (presence) |
| 1721 | break; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1722 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1723 | |
| 1724 | if (presence) { |
| 1725 | /* disable lineouts, enable hp */ |
| 1726 | for (i = 0; i < cfg->line_outs; i++) |
| 1727 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 1728 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1729 | for (i = 0; i < cfg->speaker_outs; i++) |
| 1730 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 1731 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1732 | } else { |
| 1733 | /* enable lineouts, disable hp */ |
| 1734 | for (i = 0; i < cfg->line_outs; i++) |
| 1735 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 1736 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 1737 | for (i = 0; i < cfg->speaker_outs; i++) |
| 1738 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 1739 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1740 | } |
| 1741 | } |
| 1742 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 1743 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1744 | { |
| 1745 | switch (res >> 26) { |
| 1746 | case STAC_HP_EVENT: |
| 1747 | stac92xx_hp_detect(codec, res); |
| 1748 | break; |
| 1749 | } |
| 1750 | } |
| 1751 | |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1752 | #ifdef CONFIG_PM |
| 1753 | static int stac92xx_resume(struct hda_codec *codec) |
| 1754 | { |
| 1755 | struct sigmatel_spec *spec = codec->spec; |
| 1756 | int i; |
| 1757 | |
| 1758 | stac92xx_init(codec); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1759 | stac92xx_set_config_regs(codec); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1760 | for (i = 0; i < spec->num_mixers; i++) |
| 1761 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
| 1762 | if (spec->multiout.dig_out_nid) |
| 1763 | snd_hda_resume_spdif_out(codec); |
| 1764 | if (spec->dig_in_nid) |
| 1765 | snd_hda_resume_spdif_in(codec); |
| 1766 | |
| 1767 | return 0; |
| 1768 | } |
| 1769 | #endif |
| 1770 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1771 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 1772 | .build_controls = stac92xx_build_controls, |
| 1773 | .build_pcms = stac92xx_build_pcms, |
| 1774 | .init = stac92xx_init, |
| 1775 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1776 | .unsol_event = stac92xx_unsol_event, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1777 | #ifdef CONFIG_PM |
| 1778 | .resume = stac92xx_resume, |
| 1779 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1780 | }; |
| 1781 | |
| 1782 | static int patch_stac9200(struct hda_codec *codec) |
| 1783 | { |
| 1784 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1785 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1786 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1787 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1788 | if (spec == NULL) |
| 1789 | return -ENOMEM; |
| 1790 | |
| 1791 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1792 | spec->num_pins = 8; |
| 1793 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1794 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 1795 | stac9200_models, |
| 1796 | stac9200_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1797 | if (spec->board_config < 0) { |
| 1798 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 1799 | err = stac92xx_save_bios_config_regs(codec); |
| 1800 | if (err < 0) { |
| 1801 | stac92xx_free(codec); |
| 1802 | return err; |
| 1803 | } |
| 1804 | spec->pin_configs = spec->bios_pin_configs; |
| 1805 | } else { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1806 | spec->pin_configs = stac9200_brd_tbl[spec->board_config]; |
| 1807 | stac92xx_set_config_regs(codec); |
| 1808 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1809 | |
| 1810 | spec->multiout.max_channels = 2; |
| 1811 | spec->multiout.num_dacs = 1; |
| 1812 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 1813 | spec->adc_nids = stac9200_adc_nids; |
| 1814 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1815 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1816 | spec->num_dmics = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1817 | |
| 1818 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1819 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1820 | |
| 1821 | err = stac9200_parse_auto_config(codec); |
| 1822 | if (err < 0) { |
| 1823 | stac92xx_free(codec); |
| 1824 | return err; |
| 1825 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1826 | |
| 1827 | codec->patch_ops = stac92xx_patch_ops; |
| 1828 | |
| 1829 | return 0; |
| 1830 | } |
| 1831 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1832 | static int patch_stac925x(struct hda_codec *codec) |
| 1833 | { |
| 1834 | struct sigmatel_spec *spec; |
| 1835 | int err; |
| 1836 | |
| 1837 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1838 | if (spec == NULL) |
| 1839 | return -ENOMEM; |
| 1840 | |
| 1841 | codec->spec = spec; |
| 1842 | spec->num_pins = 8; |
| 1843 | spec->pin_nids = stac925x_pin_nids; |
| 1844 | spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, |
| 1845 | stac925x_models, |
| 1846 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 1847 | again: |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1848 | if (spec->board_config < 0) { |
| 1849 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x, using BIOS defaults\n"); |
| 1850 | err = stac92xx_save_bios_config_regs(codec); |
| 1851 | if (err < 0) { |
| 1852 | stac92xx_free(codec); |
| 1853 | return err; |
| 1854 | } |
| 1855 | spec->pin_configs = spec->bios_pin_configs; |
| 1856 | } else if (stac925x_brd_tbl[spec->board_config] != NULL){ |
| 1857 | spec->pin_configs = stac925x_brd_tbl[spec->board_config]; |
| 1858 | stac92xx_set_config_regs(codec); |
| 1859 | } |
| 1860 | |
| 1861 | spec->multiout.max_channels = 2; |
| 1862 | spec->multiout.num_dacs = 1; |
| 1863 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 1864 | spec->adc_nids = stac925x_adc_nids; |
| 1865 | spec->mux_nids = stac925x_mux_nids; |
| 1866 | spec->num_muxes = 1; |
| 1867 | spec->num_dmics = 0; |
| 1868 | |
| 1869 | spec->init = stac925x_core_init; |
| 1870 | spec->mixer = stac925x_mixer; |
| 1871 | |
| 1872 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 1873 | if (!err) { |
| 1874 | if (spec->board_config < 0) { |
| 1875 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 1876 | "available, default to model=ref\n"); |
| 1877 | spec->board_config = STAC_925x_REF; |
| 1878 | goto again; |
| 1879 | } |
| 1880 | err = -EINVAL; |
| 1881 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1882 | if (err < 0) { |
| 1883 | stac92xx_free(codec); |
| 1884 | return err; |
| 1885 | } |
| 1886 | |
| 1887 | codec->patch_ops = stac92xx_patch_ops; |
| 1888 | |
| 1889 | return 0; |
| 1890 | } |
| 1891 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1892 | static int patch_stac922x(struct hda_codec *codec) |
| 1893 | { |
| 1894 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1895 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1896 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1897 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1898 | if (spec == NULL) |
| 1899 | return -ENOMEM; |
| 1900 | |
| 1901 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1902 | spec->num_pins = 10; |
| 1903 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1904 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 1905 | stac922x_models, |
| 1906 | stac922x_cfg_tbl); |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1907 | if (spec->board_config == STAC_MACMINI) { |
| 1908 | spec->gpio_mute = 1; |
| 1909 | /* Intel Macs have all same PCI SSID, so we need to check |
| 1910 | * codec SSID to distinguish the exact models |
| 1911 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 1912 | 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] | 1913 | switch (codec->subsystem_id) { |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 1914 | case 0x106b0a00: /* MacBook First generatoin */ |
| 1915 | spec->board_config = STAC_MACBOOK; |
| 1916 | break; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 1917 | case 0x106b0200: /* MacBook Pro first generation */ |
| 1918 | spec->board_config = STAC_MACBOOK_PRO_V1; |
| 1919 | break; |
| 1920 | case 0x106b1e00: /* MacBook Pro second generation */ |
| 1921 | spec->board_config = STAC_MACBOOK_PRO_V2; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1922 | break; |
| 1923 | } |
| 1924 | } |
| 1925 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 1926 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1927 | if (spec->board_config < 0) { |
| 1928 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 1929 | "using BIOS defaults\n"); |
| 1930 | err = stac92xx_save_bios_config_regs(codec); |
| 1931 | if (err < 0) { |
| 1932 | stac92xx_free(codec); |
| 1933 | return err; |
| 1934 | } |
| 1935 | spec->pin_configs = spec->bios_pin_configs; |
| 1936 | } else if (stac922x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1937 | spec->pin_configs = stac922x_brd_tbl[spec->board_config]; |
| 1938 | stac92xx_set_config_regs(codec); |
| 1939 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1940 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1941 | spec->adc_nids = stac922x_adc_nids; |
| 1942 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 1943 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1944 | spec->num_dmics = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1945 | |
| 1946 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1947 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1948 | |
| 1949 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1950 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1951 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 1952 | if (!err) { |
| 1953 | if (spec->board_config < 0) { |
| 1954 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 1955 | "available, default to model=ref\n"); |
| 1956 | spec->board_config = STAC_D945_REF; |
| 1957 | goto again; |
| 1958 | } |
| 1959 | err = -EINVAL; |
| 1960 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1961 | if (err < 0) { |
| 1962 | stac92xx_free(codec); |
| 1963 | return err; |
| 1964 | } |
| 1965 | |
| 1966 | codec->patch_ops = stac92xx_patch_ops; |
| 1967 | |
| 1968 | return 0; |
| 1969 | } |
| 1970 | |
| 1971 | static int patch_stac927x(struct hda_codec *codec) |
| 1972 | { |
| 1973 | struct sigmatel_spec *spec; |
| 1974 | int err; |
| 1975 | |
| 1976 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1977 | if (spec == NULL) |
| 1978 | return -ENOMEM; |
| 1979 | |
| 1980 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1981 | spec->num_pins = 14; |
| 1982 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1983 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 1984 | stac927x_models, |
| 1985 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 1986 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1987 | if (spec->board_config < 0) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1988 | 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] | 1989 | err = stac92xx_save_bios_config_regs(codec); |
| 1990 | if (err < 0) { |
| 1991 | stac92xx_free(codec); |
| 1992 | return err; |
| 1993 | } |
| 1994 | spec->pin_configs = spec->bios_pin_configs; |
| 1995 | } else if (stac927x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1996 | spec->pin_configs = stac927x_brd_tbl[spec->board_config]; |
| 1997 | stac92xx_set_config_regs(codec); |
| 1998 | } |
| 1999 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2000 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2001 | case STAC_D965_3ST: |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2002 | spec->adc_nids = stac927x_adc_nids; |
| 2003 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2004 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2005 | spec->num_dmics = 0; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2006 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2007 | spec->mixer = stac9227_mixer; |
| 2008 | break; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2009 | case STAC_D965_5ST: |
| 2010 | spec->adc_nids = stac927x_adc_nids; |
| 2011 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2012 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2013 | spec->num_dmics = 0; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2014 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2015 | spec->mixer = stac9227_mixer; |
| 2016 | break; |
| 2017 | default: |
| 2018 | spec->adc_nids = stac927x_adc_nids; |
| 2019 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2020 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2021 | spec->num_dmics = 0; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2022 | spec->init = stac927x_core_init; |
| 2023 | spec->mixer = stac927x_mixer; |
| 2024 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2025 | |
| 2026 | spec->multiout.dac_nids = spec->dac_nids; |
| 2027 | |
| 2028 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2029 | if (!err) { |
| 2030 | if (spec->board_config < 0) { |
| 2031 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2032 | "available, default to model=ref\n"); |
| 2033 | spec->board_config = STAC_D965_REF; |
| 2034 | goto again; |
| 2035 | } |
| 2036 | err = -EINVAL; |
| 2037 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2038 | if (err < 0) { |
| 2039 | stac92xx_free(codec); |
| 2040 | return err; |
| 2041 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2042 | |
| 2043 | codec->patch_ops = stac92xx_patch_ops; |
| 2044 | |
| 2045 | return 0; |
| 2046 | } |
| 2047 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2048 | static int patch_stac9205(struct hda_codec *codec) |
| 2049 | { |
| 2050 | struct sigmatel_spec *spec; |
| 2051 | int err; |
| 2052 | |
| 2053 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2054 | if (spec == NULL) |
| 2055 | return -ENOMEM; |
| 2056 | |
| 2057 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2058 | spec->num_pins = 14; |
| 2059 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2060 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 2061 | stac9205_models, |
| 2062 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2063 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2064 | if (spec->board_config < 0) { |
| 2065 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
| 2066 | err = stac92xx_save_bios_config_regs(codec); |
| 2067 | if (err < 0) { |
| 2068 | stac92xx_free(codec); |
| 2069 | return err; |
| 2070 | } |
| 2071 | spec->pin_configs = spec->bios_pin_configs; |
| 2072 | } else { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2073 | spec->pin_configs = stac9205_brd_tbl[spec->board_config]; |
| 2074 | stac92xx_set_config_regs(codec); |
| 2075 | } |
| 2076 | |
| 2077 | spec->adc_nids = stac9205_adc_nids; |
| 2078 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2079 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2080 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 2081 | spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2082 | spec->dmux_nid = 0x1d; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2083 | |
| 2084 | spec->init = stac9205_core_init; |
| 2085 | spec->mixer = stac9205_mixer; |
| 2086 | |
| 2087 | spec->multiout.dac_nids = spec->dac_nids; |
| 2088 | |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 2089 | /* Configure GPIO0 as EAPD output */ |
| 2090 | snd_hda_codec_write(codec, codec->afg, 0, |
| 2091 | AC_VERB_SET_GPIO_DIRECTION, 0x00000001); |
| 2092 | /* Configure GPIO0 as CMOS */ |
| 2093 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000); |
| 2094 | /* Assert GPIO0 high */ |
| 2095 | snd_hda_codec_write(codec, codec->afg, 0, |
| 2096 | AC_VERB_SET_GPIO_DATA, 0x00000001); |
| 2097 | /* Enable GPIO0 */ |
| 2098 | snd_hda_codec_write(codec, codec->afg, 0, |
| 2099 | AC_VERB_SET_GPIO_MASK, 0x00000001); |
| 2100 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2101 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2102 | if (!err) { |
| 2103 | if (spec->board_config < 0) { |
| 2104 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2105 | "available, default to model=ref\n"); |
| 2106 | spec->board_config = STAC_9205_REF; |
| 2107 | goto again; |
| 2108 | } |
| 2109 | err = -EINVAL; |
| 2110 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2111 | if (err < 0) { |
| 2112 | stac92xx_free(codec); |
| 2113 | return err; |
| 2114 | } |
| 2115 | |
| 2116 | codec->patch_ops = stac92xx_patch_ops; |
| 2117 | |
| 2118 | return 0; |
| 2119 | } |
| 2120 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2121 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2122 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2123 | */ |
| 2124 | |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 2125 | /* static config for Sony VAIO FE550G and Sony VAIO AR */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2126 | static hda_nid_t vaio_dacs[] = { 0x2 }; |
| 2127 | #define VAIO_HP_DAC 0x5 |
| 2128 | static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; |
| 2129 | static hda_nid_t vaio_mux_nids[] = { 0x15 }; |
| 2130 | |
| 2131 | static struct hda_input_mux vaio_mux = { |
| 2132 | .num_items = 2, |
| 2133 | .items = { |
Takashi Iwai | d773781 | 2006-04-25 13:05:43 +0200 | [diff] [blame] | 2134 | /* { "HP", 0x0 }, */ |
| 2135 | { "Line", 0x1 }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2136 | { "Mic", 0x2 }, |
| 2137 | { "PCM", 0x3 }, |
| 2138 | } |
| 2139 | }; |
| 2140 | |
| 2141 | static struct hda_verb vaio_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 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
| 2147 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ |
| 2148 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 2149 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 2150 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 2151 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 2152 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 2153 | {} |
| 2154 | }; |
| 2155 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2156 | static struct hda_verb vaio_ar_init[] = { |
| 2157 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 2158 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 2159 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 2160 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 2161 | /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ |
| 2162 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
| 2163 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ |
| 2164 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 2165 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 2166 | /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ |
| 2167 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 2168 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 2169 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 2170 | {} |
| 2171 | }; |
| 2172 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2173 | /* bind volumes of both NID 0x02 and 0x05 */ |
| 2174 | static int vaio_master_vol_put(struct snd_kcontrol *kcontrol, |
| 2175 | struct snd_ctl_elem_value *ucontrol) |
| 2176 | { |
| 2177 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2178 | long *valp = ucontrol->value.integer.value; |
| 2179 | int change; |
| 2180 | |
| 2181 | change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, |
| 2182 | 0x7f, valp[0] & 0x7f); |
| 2183 | change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, |
| 2184 | 0x7f, valp[1] & 0x7f); |
| 2185 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 2186 | 0x7f, valp[0] & 0x7f); |
| 2187 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 2188 | 0x7f, valp[1] & 0x7f); |
| 2189 | return change; |
| 2190 | } |
| 2191 | |
| 2192 | /* bind volumes of both NID 0x02 and 0x05 */ |
| 2193 | static int vaio_master_sw_put(struct snd_kcontrol *kcontrol, |
| 2194 | struct snd_ctl_elem_value *ucontrol) |
| 2195 | { |
| 2196 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2197 | long *valp = ucontrol->value.integer.value; |
| 2198 | int change; |
| 2199 | |
| 2200 | change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 2201 | 0x80, (valp[0] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2202 | change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 2203 | 0x80, (valp[1] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2204 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 2205 | 0x80, (valp[0] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2206 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 2207 | 0x80, (valp[1] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2208 | return change; |
| 2209 | } |
| 2210 | |
| 2211 | static struct snd_kcontrol_new vaio_mixer[] = { |
| 2212 | { |
| 2213 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2214 | .name = "Master Playback Volume", |
| 2215 | .info = snd_hda_mixer_amp_volume_info, |
| 2216 | .get = snd_hda_mixer_amp_volume_get, |
| 2217 | .put = vaio_master_vol_put, |
Takashi Iwai | c256652 | 2006-08-17 18:21:36 +0200 | [diff] [blame] | 2218 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2219 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 2220 | }, |
| 2221 | { |
| 2222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2223 | .name = "Master Playback Switch", |
| 2224 | .info = snd_hda_mixer_amp_switch_info, |
| 2225 | .get = snd_hda_mixer_amp_switch_get, |
| 2226 | .put = vaio_master_sw_put, |
| 2227 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 2228 | }, |
| 2229 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 2230 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 2231 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 2232 | { |
| 2233 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2234 | .name = "Capture Source", |
| 2235 | .count = 1, |
| 2236 | .info = stac92xx_mux_enum_info, |
| 2237 | .get = stac92xx_mux_enum_get, |
| 2238 | .put = stac92xx_mux_enum_put, |
| 2239 | }, |
| 2240 | {} |
| 2241 | }; |
| 2242 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2243 | static struct snd_kcontrol_new vaio_ar_mixer[] = { |
| 2244 | { |
| 2245 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2246 | .name = "Master Playback Volume", |
| 2247 | .info = snd_hda_mixer_amp_volume_info, |
| 2248 | .get = snd_hda_mixer_amp_volume_get, |
| 2249 | .put = vaio_master_vol_put, |
| 2250 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 2251 | }, |
| 2252 | { |
| 2253 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2254 | .name = "Master Playback Switch", |
| 2255 | .info = snd_hda_mixer_amp_switch_info, |
| 2256 | .get = snd_hda_mixer_amp_switch_get, |
| 2257 | .put = vaio_master_sw_put, |
| 2258 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 2259 | }, |
| 2260 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 2261 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 2262 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 2263 | /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT), |
| 2264 | HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/ |
| 2265 | { |
| 2266 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2267 | .name = "Capture Source", |
| 2268 | .count = 1, |
| 2269 | .info = stac92xx_mux_enum_info, |
| 2270 | .get = stac92xx_mux_enum_get, |
| 2271 | .put = stac92xx_mux_enum_put, |
| 2272 | }, |
| 2273 | {} |
| 2274 | }; |
| 2275 | |
| 2276 | static struct hda_codec_ops stac9872_patch_ops = { |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2277 | .build_controls = stac92xx_build_controls, |
| 2278 | .build_pcms = stac92xx_build_pcms, |
| 2279 | .init = stac92xx_init, |
| 2280 | .free = stac92xx_free, |
| 2281 | #ifdef CONFIG_PM |
| 2282 | .resume = stac92xx_resume, |
| 2283 | #endif |
| 2284 | }; |
| 2285 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2286 | enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ |
| 2287 | CXD9872RD_VAIO, |
| 2288 | /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ |
| 2289 | STAC9872AK_VAIO, |
| 2290 | /* Unknown. id=0x83847661 and subsys=0x104D1200. */ |
| 2291 | STAC9872K_VAIO, |
| 2292 | /* AR Series. id=0x83847664 and subsys=104D1300 */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2293 | CXD9872AKD_VAIO, |
| 2294 | STAC_9872_MODELS, |
| 2295 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2296 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2297 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 2298 | [CXD9872RD_VAIO] = "vaio", |
| 2299 | [CXD9872AKD_VAIO] = "vaio-ar", |
| 2300 | }; |
| 2301 | |
| 2302 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 2303 | SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 2304 | SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 2305 | SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), |
Tobin Davis | 68e2254 | 2007-03-12 11:36:39 +0100 | [diff] [blame] | 2306 | SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2307 | {} |
| 2308 | }; |
| 2309 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2310 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2311 | { |
| 2312 | struct sigmatel_spec *spec; |
| 2313 | int board_config; |
| 2314 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2315 | board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 2316 | stac9872_models, |
| 2317 | stac9872_cfg_tbl); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2318 | if (board_config < 0) |
| 2319 | /* unknown config, let generic-parser do its job... */ |
| 2320 | return snd_hda_parse_generic_codec(codec); |
| 2321 | |
| 2322 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2323 | if (spec == NULL) |
| 2324 | return -ENOMEM; |
| 2325 | |
| 2326 | codec->spec = spec; |
| 2327 | switch (board_config) { |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2328 | case CXD9872RD_VAIO: |
| 2329 | case STAC9872AK_VAIO: |
| 2330 | case STAC9872K_VAIO: |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2331 | spec->mixer = vaio_mixer; |
| 2332 | spec->init = vaio_init; |
| 2333 | spec->multiout.max_channels = 2; |
| 2334 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 2335 | spec->multiout.dac_nids = vaio_dacs; |
| 2336 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 2337 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 2338 | spec->adc_nids = vaio_adcs; |
| 2339 | spec->input_mux = &vaio_mux; |
| 2340 | spec->mux_nids = vaio_mux_nids; |
| 2341 | break; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2342 | |
| 2343 | case CXD9872AKD_VAIO: |
| 2344 | spec->mixer = vaio_ar_mixer; |
| 2345 | spec->init = vaio_ar_init; |
| 2346 | spec->multiout.max_channels = 2; |
| 2347 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 2348 | spec->multiout.dac_nids = vaio_dacs; |
| 2349 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 2350 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 2351 | spec->adc_nids = vaio_adcs; |
| 2352 | spec->input_mux = &vaio_mux; |
| 2353 | spec->mux_nids = vaio_mux_nids; |
| 2354 | break; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2355 | } |
| 2356 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2357 | codec->patch_ops = stac9872_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 2358 | return 0; |
| 2359 | } |
| 2360 | |
| 2361 | |
| 2362 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2363 | * patch entries |
| 2364 | */ |
| 2365 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
| 2366 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 2367 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 2368 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 2369 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 2370 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 2371 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 2372 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 2373 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 2374 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 2375 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 2376 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 2377 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 2378 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2379 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 2380 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 2381 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 2382 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 2383 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 2384 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 2385 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 2386 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 2387 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 2388 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2389 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 2390 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 2391 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 2392 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 2393 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 2394 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 2395 | /* The following does not take into account .id=0x83847661 when subsys = |
| 2396 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 2397 | * currently not fully supported. |
| 2398 | */ |
| 2399 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 2400 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 2401 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2402 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 2403 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 2404 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 2405 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 2406 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 2407 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 2408 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 2409 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2410 | {} /* terminator */ |
| 2411 | }; |